diff --git a/radicle-httpd/Cargo.toml b/radicle-httpd/Cargo.toml index 2c50bfb52..93825e6cf 100644 --- a/radicle-httpd/Cargo.toml +++ b/radicle-httpd/Cargo.toml @@ -16,14 +16,14 @@ logfmt = [ [dependencies] anyhow = { version = "1" } -axum = { version = "0.6.7", default-features = false, features = ["headers", "json", "query", "tokio"] } -axum-auth = { version= "0.4.0", default-features = false, features = ["auth-bearer"] } +axum = { version = "0.7.2", default-features = false, features = ["json", "query", "tokio", "http1"] } +axum-auth = { version= "0.7.0", default-features = false, features = ["auth-bearer"] } axum-server = { version = "0.5.1", default-features = false } base64 = "0.21.3" chrono = { version = "0.4.22", default-features = false, features = ["clock"] } fastrand = { version = "2.0.0" } flate2 = { version = "1" } -hyper = { version = "0.14.17", default-features = false } +hyper = { version = "1.0.1", default-features = false } lexopt = { version = "0.2.1" } lru = { version = "0.11.0" } nonempty = { version = "0.8.1", features = ["serialize"] } @@ -33,7 +33,7 @@ serde_json = { version = "1", features = ["preserve_order"] } thiserror = { version = "1" } time = { version = "0.3.17", features = ["parsing", "serde"] } tokio = { version = "1.21", default-features = false, features = ["macros", "rt-multi-thread"] } -tower-http = { version = "0.3.4", default-features = false, features = ["trace", "cors", "set-header"] } +tower-http = { version = "0.5", default-features = false, features = ["trace", "cors", "set-header"] } tracing = { version = "0.1.37", default-features = false, features = ["std", "log"] } tracing-logfmt = { version = "0.2", optional = true } tracing-subscriber = { version = "0.3", default-features = false, features = ["std", "ansi", "fmt"] } @@ -50,7 +50,7 @@ path = "../radicle-term" path = "../radicle-cli" [dev-dependencies] -hyper = { version = "0.14.17", default-features = false, features = ["client"] } +hyper = { version = "1.0.1", default-features = false, features = ["client"] } pretty_assertions = { version = "1.3.0" } radicle-cli = { path = "../radicle-cli" } radicle-crypto = { path = "../radicle-crypto", features = ["test"] } diff --git a/radicle-httpd/src/lib.rs b/radicle-httpd/src/lib.rs index 4fae7f24f..61822bc0a 100644 --- a/radicle-httpd/src/lib.rs +++ b/radicle-httpd/src/lib.rs @@ -13,10 +13,11 @@ use std::sync::Arc; use std::time::Duration; use anyhow::Context as _; -use axum::body::{Body, BoxBody, HttpBody}; +use axum::body::{Body, HttpBody}; use axum::http::{Request, Response}; use axum::middleware; use axum::Router; +use tokio::net::TcpListener; use tower_http::trace::TraceLayer; use tracing::Span; @@ -54,9 +55,9 @@ pub async fn run(options: Options) -> anyhow::Result<()> { tracing::info!("{}", str::from_utf8(&git_version)?.trim()); - let listen = options.listen; + let listener = TcpListener::bind(options.listen).await?; - tracing::info!("listening on http://{}", listen); + tracing::info!("listening on http://{}", options.listen); let profile = Profile::load()?; let request_id = RequestId::new(); @@ -72,7 +73,7 @@ pub async fn run(options: Options) -> anyhow::Result<()> { tracing::info_span!("request", id = %request_id.clone().next()) }) .on_response( - |response: &Response, latency: Duration, _span: &Span| { + |response: &Response, latency: Duration, _span: &Span| { if let Some(info) = response.extensions().get::() { tracing::info!( "{} \"{} {} {:?}\" {} {:?} {}", @@ -100,8 +101,7 @@ pub async fn run(options: Options) -> anyhow::Result<()> { ) .into_make_service_with_connect_info::(); - axum::Server::bind(&listen) - .serve(app) + axum::serve(listener, app) .await .map_err(anyhow::Error::from) } diff --git a/radicle-httpd/src/test.rs b/radicle-httpd/src/test.rs index c227af01e..744baf98c 100644 --- a/radicle-httpd/src/test.rs +++ b/radicle-httpd/src/test.rs @@ -381,6 +381,8 @@ impl Response { } pub async fn body(self) -> Bytes { - hyper::body::to_bytes(self.0.into_body()).await.unwrap() + axum::body::to_bytes(self.0.into_body(), usize::MAX) + .await + .unwrap() } } diff --git a/radicle-httpd/src/tracing_extra.rs b/radicle-httpd/src/tracing_extra.rs index 91cecae51..bb61321f3 100644 --- a/radicle-httpd/src/tracing_extra.rs +++ b/radicle-httpd/src/tracing_extra.rs @@ -3,6 +3,7 @@ use std::net::SocketAddr; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::Arc; +use axum::body::Body; use axum::extract::ConnectInfo; use axum::http::Request; use axum::middleware::Next; @@ -25,6 +26,7 @@ impl RequestId { } } +#[derive(Clone)] pub struct TracingInfo { pub connect_info: ConnectInfo, pub method: Method, @@ -45,7 +47,7 @@ impl fmt::Display for ColoredStatus { } } -pub async fn tracing_middleware(request: Request, next: Next) -> impl IntoResponse { +pub async fn tracing_middleware(request: Request, next: Next) -> impl IntoResponse { let connect_info = *request .extensions() .get::>()