blob: 68839039ba84f0bf11d483f77ab78450833ea852 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
pub mod api_server;
mod router;
mod error;
mod bucket;
mod cluster;
mod key;
use serde::{Deserialize};
use hyper::{Request, Body};
use error::*;
pub async fn parse_json_body<T: for<'de> Deserialize<'de>>(req: Request<Body>) -> Result<T, Error> {
let body = hyper::body::to_bytes(req.into_body()).await?;
let resp: T = serde_json::from_slice(&body).ok_or_bad_request("Invalid JSON")?;
Ok(resp)
}
|