server/rest: code cleanup: use async

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-10-12 10:36:32 +02:00
parent dd76eba73e
commit 07995a3ca3

View File

@ -140,9 +140,10 @@ impl tower_service::Service<Request<Body>> for ApiService {
let path = req.uri().path().to_owned();
let method = req.method().clone();
let config = Arc::clone(&self.api_config);
let peer = self.peer;
handle_request(self.api_config.clone(), req)
.map(move |result| match result {
async move {
match handle_request(config, req).await {
Ok(res) => {
log_response(&peer, method, &path, &res);
Ok::<_, Self::Error>(res)
@ -160,8 +161,9 @@ impl tower_service::Service<Request<Body>> for ApiService {
Ok(resp)
}
}
})
.boxed()
}
}
.boxed()
}
}