mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-06 23:53:38 +00:00
fixups for new hyper alpha
Body's Streawm impl was put behind the 'unstable-stream' feature, so we won't be using it for now. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
29893d66ae
commit
01de528fc3
@ -13,7 +13,7 @@ endian_trait = { version = "0.6", features = [ "arrays" ] }
|
|||||||
failure = "0.1"
|
failure = "0.1"
|
||||||
futures-preview = "0.3.0-alpha"
|
futures-preview = "0.3.0-alpha"
|
||||||
http = "0.1"
|
http = "0.1"
|
||||||
hyper = { version = "0.13.0-alpha.1" }
|
hyper = { version = "0.13.0-alpha.2" }
|
||||||
lazy_static = "1.3"
|
lazy_static = "1.3"
|
||||||
proxmox = { path = "../proxmox", features = [ "api-macro" ] }
|
proxmox = { path = "../proxmox", features = [ "api-macro" ] }
|
||||||
regex = "1.1"
|
regex = "1.1"
|
||||||
|
@ -179,6 +179,14 @@ async fn update_mount_point(id: String, entry: MountEntry) -> Result<String, Err
|
|||||||
// Hyper glue
|
// Hyper glue
|
||||||
//
|
//
|
||||||
|
|
||||||
|
async fn json_body(mut body: Body) -> Result<Value, Error> {
|
||||||
|
let mut data = Vec::new();
|
||||||
|
while let Some(chunk) = body.next().await {
|
||||||
|
data.extend(chunk?);
|
||||||
|
}
|
||||||
|
Ok(serde_json::from_str(std::str::from_utf8(&data)?)?)
|
||||||
|
}
|
||||||
|
|
||||||
async fn route_request(request: Request<Body>) -> Result<http::Response<Body>, Error> {
|
async fn route_request(request: Request<Body>) -> Result<http::Response<Body>, Error> {
|
||||||
let (parts, body) = request.into_parts();
|
let (parts, body) = request.into_parts();
|
||||||
let path = parts.uri.path();
|
let path = parts.uri.path();
|
||||||
@ -198,9 +206,7 @@ async fn route_request(request: Request<Body>) -> Result<http::Response<Body>, E
|
|||||||
|
|
||||||
if let Some(ty) = parts.headers.get(http::header::CONTENT_TYPE) {
|
if let Some(ty) = parts.headers.get(http::header::CONTENT_TYPE) {
|
||||||
if ty.to_str()? == "application/json" {
|
if ty.to_str()? == "application/json" {
|
||||||
use futures::stream::TryStreamExt;
|
let json = json_body(body).await?;
|
||||||
let json =
|
|
||||||
serde_json::from_str(std::str::from_utf8(body.try_concat().await?.as_ref())?)?;
|
|
||||||
match json {
|
match json {
|
||||||
Value::Object(map) => {
|
Value::Object(map) => {
|
||||||
for (k, v) in map {
|
for (k, v) in map {
|
||||||
|
Loading…
Reference in New Issue
Block a user