aboutsummaryrefslogblamecommitdiff
path: root/src/api/admin/mod.rs
blob: 73700e6e25959b55305b40ae49f7449f5e85ce37 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                   
          
           
 
           
            
        
 

                           







                                                                                                    
pub mod api_server;
mod error;
mod router;

mod bucket;
mod cluster;
mod key;

use hyper::{Body, Request};
use serde::Deserialize;

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)
}