aboutsummaryrefslogtreecommitdiff
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
parent73ba7f8139f171187e7fd35abea10587f4bef324 (diff)
Working on lockchain integration
-rw-r--r--Cargo.lock41
-rw-r--r--lockchain-http/Cargo.toml1
-rw-r--r--lockchain-http/examples/simple-http.rs2
-rw-r--r--lockchain-http/src/handlers.rs2
-rw-r--r--lockchain-http/src/lib.rs15
5 files changed, 54 insertions, 7 deletions
diff --git a/Cargo.lock b/Cargo.lock
index b333fc7..59ff947 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -532,6 +532,18 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "env_logger"
+version = "0.5.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "error-chain"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -680,6 +692,14 @@ version = "1.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "humantime"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "idna"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -826,6 +846,7 @@ version = "0.1.1"
dependencies = [
"actix 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-web 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
"lockchain-core 0.7.1",
"serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1419,6 +1440,14 @@ dependencies = [
]
[[package]]
+name = "termcolor"
+version = "0.3.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "termion"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1777,6 +1806,14 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "wincolor"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "winreg"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1857,6 +1894,7 @@ dependencies = [
"checksum encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a"
"checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18"
"checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
+"checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a"
"checksum error-chain 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faa976b4fd2e4c2b2f3f486874b19e61944d3de3de8b61c9fcf835d583871bcc"
"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"
"checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46"
@@ -1876,6 +1914,7 @@ dependencies = [
"checksum http 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "75df369fd52c60635208a4d3e694777c099569b3dcf4844df8f652dc004644ab"
"checksum http-range 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2e4003e6fd05ea9109db00415e670b11f511a42e567ff2d5d771cbdfa24e02"
"checksum httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2f407128745b78abc95c0ffbe4e5d37427fdc0d45470710cfef8c44522a2e37"
+"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e"
"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d"
"checksum indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08173ba1e906efb6538785a8844dd496f5d34f0a2d88038e95195172fc667220"
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
@@ -1960,6 +1999,7 @@ dependencies = [
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
"checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd"
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
+"checksum termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "adc4587ead41bf016f11af03e55a624c06568b5a19db4e90fde573d805074f83"
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693"
"checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963"
@@ -2001,6 +2041,7 @@ dependencies = [
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+"checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767"
"checksum winreg 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a27a759395c1195c4cc5cda607ef6f8f6498f64e78f7900f5de0a127a424704a"
"checksum winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e"
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
diff --git a/lockchain-http/Cargo.toml b/lockchain-http/Cargo.toml
index 09f4843..b6c832a 100644
--- a/lockchain-http/Cargo.toml
+++ b/lockchain-http/Cargo.toml
@@ -12,6 +12,7 @@ license = "MIT/X11 OR Apache-2.0"
[dependencies]
lockchain-core = { version = "0.7.0", path = "../lockchain-core" }
+env_logger = "0.5"
# Serialisation stack
serde = "1.0"
diff --git a/lockchain-http/examples/simple-http.rs b/lockchain-http/examples/simple-http.rs
index a2855df..1811c08 100644
--- a/lockchain-http/examples/simple-http.rs
+++ b/lockchain-http/examples/simple-http.rs
@@ -6,4 +6,4 @@ fn main() {
use lockchain_http::start_server;
start_server::<EncryptedBody>("localhost", "8888");
-} \ No newline at end of file
+}
diff --git a/lockchain-http/src/handlers.rs b/lockchain-http/src/handlers.rs
index d4f707e..6b9e641 100644
--- a/lockchain-http/src/handlers.rs
+++ b/lockchain-http/src/handlers.rs
@@ -6,6 +6,8 @@ use lockchain::{traits::Body, Record};
use model::CarrierMessage;
/// PUT /vault
+///
+///
pub fn create_vault(_req: HttpRequest) -> impl Responder {
format!("Unimplemented!")
}
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)
})