aboutsummaryrefslogtreecommitdiff
path: root/lockchain-http
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2018-06-22 21:17:51 +0200
committerKatharina Fey <kookie@spacekookie.de>2018-06-22 21:17:51 +0200
commitdc7d3725547c483b0357c7c07a68c0814f046f87 (patch)
treecad3c8b6e6ef2160e74f21d50a56847bbad24715 /lockchain-http
parent08adf3d4fe66991e1c01e012c78c65898367bda9 (diff)
Bumping all dependencies
Diffstat (limited to 'lockchain-http')
-rw-r--r--lockchain-http/src/handlers.rs5
-rw-r--r--lockchain-http/src/model.rs8
-rw-r--r--lockchain-http/src/state.rs4
3 files changed, 16 insertions, 1 deletions
diff --git a/lockchain-http/src/handlers.rs b/lockchain-http/src/handlers.rs
index 47beb59..bda91ae 100644
--- a/lockchain-http/src/handlers.rs
+++ b/lockchain-http/src/handlers.rs
@@ -78,11 +78,14 @@ where
}
/// GET /vault/{vault-id}/records/{record-id}
-pub fn get_record<B, V>(req: HttpRequestState<ApiState<B, V>>) -> impl Responder
+pub fn get_record<B, V>((item, req): (Json<GetRecord>, HttpRequestState<ApiState<B, V>>) -> impl Responder
where
B: Body,
V: Vault<B>,
{
+ let state = req.state().lock().unwrap();
+ let vault = state.get_vault("");
+
Json(OperationFailed {
reason: "Not implemented".into(),
code: 255,
diff --git a/lockchain-http/src/model.rs b/lockchain-http/src/model.rs
index 63a71c3..c836707 100644
--- a/lockchain-http/src/model.rs
+++ b/lockchain-http/src/model.rs
@@ -45,6 +45,14 @@ pub struct VaultCreate {
pub location: String,
}
+/// Query to get a record
+#[derive(Serialize, Deserialize)]
+pub struct GetRecord {
+ pub name: String,
+ pub range: Option<(u32, u32),
+}
+
+
/// Response to creating a new vault
#[derive(Serialize, Deserialize)]
pub struct VaultCreateResponse {
diff --git a/lockchain-http/src/state.rs b/lockchain-http/src/state.rs
index 72a34af..a1a67d3 100644
--- a/lockchain-http/src/state.rs
+++ b/lockchain-http/src/state.rs
@@ -57,6 +57,10 @@ where
pub fn add_vault(&mut self, name: &str, vault: V) {
self.vaults.insert(name.into(), Some(vault));
}
+
+ pub fn get_vault(&mut self, name: &str) -> Option<&mut V> {
+ self.vaults.get_mut(name)
+ }
}
impl<B, V> Default for ApiState<B, V>