Function lockchain_http::create_server [−][src]
pub fn create_server<B: Body + 'static>(
bind: &str,
port: &str,
state: impl Vault<B> + 'static
) -> HttpServer<App<Arc<Mutex<impl 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();