aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2018-06-22 22:27:39 +0200
committerKatharina Fey <kookie@spacekookie.de>2018-06-22 22:27:39 +0200
commiteb62b89c0d53dc4bb0fe9fd5a1a337289ea4ab53 (patch)
tree83a4c24bf9404b12a28cc435ad89b6e59edf91d7
parentdc7d3725547c483b0357c7c07a68c0814f046f87 (diff)
Fixing a bunch of syntax errors in the code
-rw-r--r--lockchain-http/src/handlers.rs6
-rw-r--r--lockchain-http/src/lib.rs4
-rw-r--r--lockchain-http/src/model.rs3
-rw-r--r--lockchain-http/src/state.rs2
4 files changed, 7 insertions, 8 deletions
diff --git a/lockchain-http/src/handlers.rs b/lockchain-http/src/handlers.rs
index bda91ae..e7d0a11 100644
--- a/lockchain-http/src/handlers.rs
+++ b/lockchain-http/src/handlers.rs
@@ -78,12 +78,14 @@ where
}
/// GET /vault/{vault-id}/records/{record-id}
-pub fn get_record<B, V>((item, req): (Json<GetRecord>, HttpRequestState<ApiState<B, V>>) -> impl Responder
+pub fn get_record<B, V>(
+ (item, req): (Json<VaultCreate>, HttpRequestState<ApiState<B, V>>),
+) -> impl Responder
where
B: Body,
V: Vault<B>,
{
- let state = req.state().lock().unwrap();
+ let mut state = req.state().lock().unwrap();
let vault = state.get_vault("");
Json(OperationFailed {
diff --git a/lockchain-http/src/lib.rs b/lockchain-http/src/lib.rs
index 85198b8..c9ea213 100644
--- a/lockchain-http/src/lib.rs
+++ b/lockchain-http/src/lib.rs
@@ -71,12 +71,10 @@ where
r.method(http::Method::GET).with(handlers::get_vaults);
r.method(http::Method::PUT).with(handlers::create_vault);
})
- // .resource("/vaults", |r| {
- // })
.resource("/vaults/{vaultid}", |r| r.f(handlers::update_vault))
.resource("/vaults/{vaultid}", |r| r.f(handlers::delete_vault))
.resource("/vaults/{vaultid}/records/{recordid}", |r| {
- r.f(handlers::get_record)
+ r.method(http::Method::GET).with(handlers::get_record);
})
.resource("/vaults/{vaultid}/records", |r| {
r.f(handlers::create_record)
diff --git a/lockchain-http/src/model.rs b/lockchain-http/src/model.rs
index c836707..8ab79f4 100644
--- a/lockchain-http/src/model.rs
+++ b/lockchain-http/src/model.rs
@@ -49,10 +49,9 @@ pub struct VaultCreate {
#[derive(Serialize, Deserialize)]
pub struct GetRecord {
pub name: String,
- pub range: Option<(u32, u32),
+ 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 a1a67d3..4677632 100644
--- a/lockchain-http/src/state.rs
+++ b/lockchain-http/src/state.rs
@@ -59,7 +59,7 @@ where
}
pub fn get_vault(&mut self, name: &str) -> Option<&mut V> {
- self.vaults.get_mut(name)
+ self.vaults.get_mut(name)?.as_mut()
}
}