mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-20 18:12:15 +00:00
[dep-upgrade-202402] prepare migration to http/hyper 1.0
This commit is contained in:
+2
-2
@@ -1,4 +1,4 @@
|
||||
use hyper::{Body, Request, Response};
|
||||
use hyper::{body::HttpBody, Body, Request, Response};
|
||||
use idna::domain_to_unicode;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -139,7 +139,7 @@ pub fn key_after_prefix(pfx: &str) -> Option<String> {
|
||||
}
|
||||
|
||||
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 body = req.into_body().collect().await?.to_bytes();
|
||||
let resp: T = serde_json::from_slice(&body).ok_or_bad_request("Invalid JSON")?;
|
||||
Ok(resp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user