api2: update for latest proxmox-api changes

- rename ApiFuture into ApiResponseFuture
- impl. ApiHandler::Async
This commit is contained in:
Dietmar Maurer 2019-12-16 09:59:45 +01:00
parent 9717c1b4eb
commit 3e2c83471a
2 changed files with 8 additions and 2 deletions

View File

@ -7,7 +7,7 @@ use std::task::{Context, Poll};
use futures::*;
use hyper::{Body, Request, Response, StatusCode};
use proxmox::api::{http_err, ApiFuture, HttpError, Router, RpcEnvironment};
use proxmox::api::{http_err, ApiResponseFuture, HttpError, Router, RpcEnvironment};
use crate::tools;
use crate::server::formatter::*;
@ -35,7 +35,7 @@ impl <E: RpcEnvironment + Clone> H2Service<E> {
if self.debug { self.worker.log(msg); }
}
fn handle_request(&self, req: Request<Body>) -> ApiFuture {
fn handle_request(&self, req: Request<Body>) -> ApiResponseFuture {
let (parts, body) = req.into_parts();

View File

@ -285,6 +285,12 @@ pub async fn handle_api_request<Env: RpcEnvironment, S: 'static + BuildHasher +
(handler)(params, info, &mut rpcenv)
.map(|data| (formatter.format_data)(data, &rpcenv))
}
ApiHandler::Async(handler) => {
let params = get_request_parameters(info.parameters, parts, req_body, uri_param).await?;
(handler)(params, info, &mut rpcenv)
.await
.map(|data| (formatter.format_data)(data, &rpcenv))
}
};
let resp = match result {