formatting cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-08-21 10:15:42 +02:00
parent acbf549bf0
commit 68f4a68bc1

View File

@ -199,14 +199,11 @@ async fn route_request(request: Request<Body>) -> Result<http::Response<Body>, E
if let Some(ty) = parts.headers.get(http::header::CONTENT_TYPE) { if let Some(ty) = parts.headers.get(http::header::CONTENT_TYPE) {
if ty.to_str()? == "application/json" { if ty.to_str()? == "application/json" {
use futures::stream::TryStreamExt; use futures::stream::TryStreamExt;
let json = serde_json::from_str(std::str::from_utf8( let json =
body serde_json::from_str(std::str::from_utf8(body.try_concat().await?.as_ref())?)?;
.try_concat()
.await?
.as_ref()
)?)?;
match json { match json {
Value::Object(map) => for (k, v) in map { Value::Object(map) => {
for (k, v) in map {
let existed = params let existed = params
.get_or_insert_with(serde_json::Map::new) .get_or_insert_with(serde_json::Map::new)
.insert(k, v) .insert(k, v)
@ -215,6 +212,7 @@ async fn route_request(request: Request<Body>) -> Result<http::Response<Body>, E
bail!("tried to override path-based parameter!"); bail!("tried to override path-based parameter!");
} }
} }
}
_ => bail!("expected a json object"), _ => bail!("expected a json object"),
} }
} }