freechat/server/src/http_params.rs
shockrah a074498f61 - removed dead code
- removed mutability in return object (parse_params)
2020-07-04 21:18:11 -07:00

10 lines
339 B
Rust

use serde_json::{self, Value};
use hyper::body::{to_bytes, Bytes};
use hyper::Body;
use std::u8;
pub async fn parse_params(body_raw: &mut Body) -> Result<Value, serde_json::error::Error> {
let bytes: &[u8] = &*to_bytes(body_raw).await.unwrap(); // rarely fails
let values: Value = serde_json::from_slice(bytes)?;
Ok(values)
}