diff --git a/http/src/v0/block.rs b/http/src/v0/block.rs index 36057f6c..30b37078 100644 --- a/http/src/v0/block.rs +++ b/http/src/v0/block.rs @@ -17,13 +17,18 @@ use warp::{http::Response, path, query, reply, Filter, Rejection, Reply}; mod options; use options::RmOptions; +// This is parsed for both `block/get` and `block/stat`. Should there be any need to add stuff to +// either which isn't relevant in the other, go ahead and split these again. #[derive(Debug, Deserialize)] -pub struct GetQuery { +pub struct GetStatOptions { arg: String, timeout: Option>, } -async fn get_query(ipfs: Ipfs, query: GetQuery) -> Result { +async fn get_query( + ipfs: Ipfs, + query: GetStatOptions, +) -> Result { let cid: Cid = query.arg.parse().map_err(StringError::from)?; let data = ipfs .get_block(&cid) @@ -42,7 +47,7 @@ pub fn get( ) -> impl Filter + Clone { path!("block" / "get") .and(with_ipfs(ipfs)) - .and(query::()) + .and(query::()) .and_then(get_query) } @@ -208,12 +213,6 @@ async fn rm_query( Ok(StreamResponse(st)) } -#[derive(Debug, Deserialize)] -pub struct StatQuery { - arg: String, - timeout: Option>, -} - #[derive(Debug, Serialize)] #[serde(rename_all = "PascalCase")] pub struct StatResponse { @@ -223,7 +222,7 @@ pub struct StatResponse { async fn stat_query( ipfs: Ipfs, - query: StatQuery, + query: GetStatOptions, ) -> Result { let cid: Cid = query.arg.parse().map_err(StringError::from)?; let block = ipfs @@ -245,6 +244,6 @@ pub fn stat( ) -> impl Filter + Clone { path!("block" / "stat") .and(with_ipfs(ipfs)) - .and(query::()) + .and(query::()) .and_then(stat_query) }