rest-server: use hypers AddrIncoming for proxmox-backup-api

this has a 'from_listener' (tokio::net::TcpListener) since hyper 0.14.5 in
the 'tcp' feature (we use 'full', which includes that; since 0.14.13
it is not behind a feature flag anymore).

this makes it possible to create a hyper server without our
'StaticIncoming' wrapper and thus makes it unnecessary.

The only other thing we have to do is to change the Service impl from
tokio::net::TcpStream to hyper::server::conn::AddStream to fulfill the trait
requirements.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dominik Csapak
2021-09-29 09:04:17 +02:00
committed by Thomas Lamprecht
parent 99940358e3
commit 6f0565fa60
3 changed files with 11 additions and 12 deletions

View File

@ -108,7 +108,8 @@ async fn run() -> Result<(), Error> {
let server = daemon::create_daemon(
([127,0,0,1], 82).into(),
move |listener, ready| {
let incoming = proxmox_backup::tools::async_io::StaticIncoming::from(listener);
let incoming = hyper::server::conn::AddrIncoming::from_listener(listener)?;
Ok(ready
.and_then(|_| hyper::Server::builder(incoming)
.serve(rest_server)