From 28b2a6b9eda45946ffd52020ed4f772ad18b9616 Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Sun, 10 Jun 2018 20:32:38 +0200 Subject: Removing User & Login traits from core, adding a metadata store to take their place --- lockchain-http/src/handlers.rs | 2 ++ lockchain-http/src/lib.rs | 9 +++++++-- lockchain-http/src/model.rs | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'lockchain-http/src') diff --git a/lockchain-http/src/handlers.rs b/lockchain-http/src/handlers.rs index 64d0b8a..77bc823 100644 --- a/lockchain-http/src/handlers.rs +++ b/lockchain-http/src/handlers.rs @@ -12,6 +12,8 @@ use std::sync::{Arc, Mutex}; type HttpRequestState = HttpRequest>>; /// PUT /vault +/// +/// Check the documentation for more information about how to provide payloads pub fn create_vault(_req: HttpRequestState>) -> impl Responder { format!("Unimplemented!") } diff --git a/lockchain-http/src/lib.rs b/lockchain-http/src/lib.rs index 5192de2..a3872e1 100644 --- a/lockchain-http/src/lib.rs +++ b/lockchain-http/src/lib.rs @@ -10,6 +10,9 @@ //! //! Ideally this shim-layer version should be the same as the `lockchain-core` it binds //! against, however especially during development this won't always be the case. +//! +//! **Note**: API endpoint documentation can be found +//! [here](https://github.com/spacekookie/lockchain/tree/master/lockchain-http#api-reference) #[macro_use] extern crate serde_derive; @@ -23,7 +26,7 @@ mod handlers; mod model; pub use model::CarrierMessage; -use actix_web::{server, App}; +use actix_web::{http, server, App}; use lockchain::traits::{Body, Vault}; use std::sync::{Arc, Mutex}; @@ -58,7 +61,9 @@ pub fn create_server( server::new(move || { vec![ App::with_state(Arc::clone(&state)) - .resource("/vault", |r| r.f(handlers::create_vault)) + .resource("/vault", |r| { + r.method(http::Method::PUT).with(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| { diff --git a/lockchain-http/src/model.rs b/lockchain-http/src/model.rs index c775ee6..f9e2665 100644 --- a/lockchain-http/src/model.rs +++ b/lockchain-http/src/model.rs @@ -14,3 +14,10 @@ pub struct CarrierMessage { #[serde(bound(deserialize = "T: Serialize + DeserializeOwned"))] pub data: Option, } + +/// Fields provided when creating a new vault +#[derive(Serialize, Deserialize)] +pub struct VaultCreate { + name: String, + location: String, +} -- cgit v1.2.3