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
1 changed files with 6 additions and 4 deletions

View File

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