diff options
author | Katharina Fey <kookie@spacekookie.de> | 2018-06-12 01:24:27 +0200 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2018-06-12 01:24:27 +0200 |
commit | 5e4a2c1df2aceef1ad736f6ddd9d3170711a8510 (patch) | |
tree | 36ed4a8b83ed2d6e061d2622e26420a30e8f6aa3 /lockchain-http/src/handlers.rs | |
parent | 8cbd45f0af5fda64c409c9486b7a6d40814ef2d7 (diff) |
Adding /api and /vault endpoints as first working routes ✨
Diffstat (limited to 'lockchain-http/src/handlers.rs')
-rw-r--r-- | lockchain-http/src/handlers.rs | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lockchain-http/src/handlers.rs b/lockchain-http/src/handlers.rs index 77bc823..4fc3c27 100644 --- a/lockchain-http/src/handlers.rs +++ b/lockchain-http/src/handlers.rs @@ -5,14 +5,25 @@ use lockchain::{ traits::{Body, Vault}, Record, }; -use model::CarrierMessage; +use model::*; use std::sync::{Arc, Mutex}; type HttpRequestState<T> = HttpRequest<Arc<Mutex<T>>>; +/// GET /vault +/// +/// Check the documentation for more information about how to provide payloads +pub fn get_vaults<B: Body>(req: HttpRequestState<impl Vault<B>>) -> impl Responder { + let meta = req.state().lock().unwrap().metadata(); + Json(VaultList { + vaults: vec![meta.name], + count: meta.size, + }) +} + /// PUT /vault -/// +/// /// Check the documentation for more information about how to provide payloads pub fn create_vault<B: Body>(_req: HttpRequestState<impl Vault<B>>) -> impl Responder { format!("Unimplemented!") @@ -64,3 +75,15 @@ pub fn authenticate<B: Body>(_req: HttpRequestState<impl Vault<B>>) -> impl Resp pub fn deauthenticate<B: Body>(_req: HttpRequestState<impl Vault<B>>) -> impl Responder { format!("Unimplemented!") } + +/// GET /api +/// +/// Check the documentation for more information about how to provide payloads +pub fn api_data<B: Body>(_: HttpRequestState<impl Vault<B>>) -> impl Responder { + Json(ApiInformation { + version: "1.0".into(), + providers: vec!["FileVault".into(), "EncryptedBody".into()], + hostname: None, + supported: "1.0".into(), + }) +} |