diff --git a/server/src/http_params.rs b/server/src/http_params.rs index d47ff3d..80d6862 100644 --- a/server/src/http_params.rs +++ b/server/src/http_params.rs @@ -1,4 +1,5 @@ -use hyper::body::{to_bytes, Bytes, HttpBody}; +use serde_json::{self, Value}; +use hyper::body::{to_bytes, Bytes}; use hyper::Body; use std::collections::HashMap; use std::u8; @@ -75,10 +76,8 @@ async fn map_body(map: &mut HashMap<&str, &str>, body_raw: &mut Body) { } } - -// NOTE: we only need an async call because map body itself makes asynchronous calls -pub async fn parse_params<'q>(qs_raw: Option<&'q str>, body_raw: &mut Body) -> HashMap<&'q str, &'q str> { - let mut qs_map = map_qs(qs_raw); - map_body(&mut qs_map, body_raw).await; - qs_map +pub async fn parse_params(body_raw: &mut Body) -> Result { + let bytes: &[u8] = &*to_bytes(body_raw).await.unwrap(); // rarely fails + let mut values: Value = serde_json::from_slice(bytes)?; + Ok(values) } \ No newline at end of file