Function lockchain_http::create_server [−][src]
pub fn create_server<B, V>(
bind: &str,
port: &str,
state: ApiState<B, V>
) -> Result<HttpApi<ApiState<B, V>>, Box<Error>> where
B: Body + 'static,
V: Vault<B> + 'static,
Create a new lockchain-http server for a vault state
Lifetime wise, vault needs to long as long as the server, which is returned to
call run()
on. Make sure this is done in a thread, to not block your
mainapplication context
Additionally, provide a address bind and port string to bind to.
Example
use lockchain_core::{traits::*, EncryptedBody};
use lockchain_http::create_server;
use lockchain_files::DataVault;
let server = create_server(
"localhost",
"8080",
DataVault::<EncryptedBody>::new("name", "some-location"),
).run();