aboutsummaryrefslogtreecommitdiff
path: root/lockchain-http/src/lib.rs
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2018-06-09 01:36:31 +0200
committerKatharina Fey <kookie@spacekookie.de>2018-06-09 01:36:31 +0200
commita7a4df2dc1a8df878db19abe9c6ee894a3342532 (patch)
tree7f4a1126822724f79d5788fc6fad4d5ca0dfde15 /lockchain-http/src/lib.rs
parent73ba7f8139f171187e7fd35abea10587f4bef324 (diff)
Working on lockchain integration
Diffstat (limited to 'lockchain-http/src/lib.rs')
-rw-r--r--lockchain-http/src/lib.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/lockchain-http/src/lib.rs b/lockchain-http/src/lib.rs
index 87327e3..1721eee 100644
--- a/lockchain-http/src/lib.rs
+++ b/lockchain-http/src/lib.rs
@@ -13,13 +13,14 @@
#[macro_use]
extern crate serde_derive;
+extern crate env_logger;
extern crate serde;
extern crate actix_web as actix;
extern crate lockchain_core as lockchain;
use actix::{server, App};
-use lockchain::traits::Body;
+use lockchain::traits::{Body, Vault};
mod handlers;
mod model;
@@ -31,18 +32,20 @@ pub use model::CarrierMessage;
/// The payload type is defined by the generic parameter provided and can
/// either be just the encrypted message body, or the decrypted message
/// body which is available via the lockchain-crypto crate
-pub fn start_server<T: 'static + Body>(iface: &str, port: &str) {
+pub fn start_server<B, V>(iface: &str, port: &str)
+where
+ B: 'static + Body,
+ V: 'static + Vault<B>,
+{
server::new(|| {
App::new()
.resource("/vault", |r| r.f(handlers::create_vault))
.resource("/vault/{vaultid}", |r| r.f(handlers::update_vault))
.resource("/vault/{vaultid}", |r| r.f(handlers::delete_vault))
.resource("/vault/{vaultid}/records/{recordid}", |r| {
- r.f(handlers::get_record::<T>)
- })
- .resource("/vault/{vaultid}/records", |r| {
- r.f(handlers::create_record)
+ r.f(handlers::get_record::<B>)
})
+ .resource("/vault/{vaultid}/records", |r| r.f(handlers::create_record))
.resource("/vault/{vaultid}/records/{recordid}", |r| {
r.f(handlers::update_record)
})