Upgrade axum

This commit is contained in:
Jonas Platte 2025-07-24 23:48:14 +02:00
parent 55a01e7113
commit cd3e01e790
No known key found for this signature in database
GPG key ID: 7D261D771D915378
5 changed files with 73 additions and 49 deletions

103
Cargo.lock generated
View file

@ -136,16 +136,43 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"axum-core", "axum-core 0.4.5",
"bytes", "bytes",
"futures-util", "futures-util",
"http", "http",
"http-body", "http-body",
"http-body-util", "http-body-util",
"itoa",
"matchit 0.7.3",
"memchr",
"mime",
"percent-encoding",
"pin-project-lite",
"rustversion",
"serde",
"sync_wrapper",
"tower 0.5.2",
"tower-layer",
"tower-service",
]
[[package]]
name = "axum"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5"
dependencies = [
"axum-core 0.5.2",
"bytes",
"form_urlencoded",
"futures-util",
"http",
"http-body",
"http-body-util",
"hyper", "hyper",
"hyper-util", "hyper-util",
"itoa", "itoa",
"matchit", "matchit 0.8.4",
"memchr", "memchr",
"mime", "mime",
"percent-encoding", "percent-encoding",
@ -181,27 +208,45 @@ dependencies = [
"sync_wrapper", "sync_wrapper",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
]
[[package]]
name = "axum-core"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6"
dependencies = [
"bytes",
"futures-core",
"http",
"http-body",
"http-body-util",
"mime",
"pin-project-lite",
"rustversion",
"sync_wrapper",
"tower-layer",
"tower-service",
"tracing", "tracing",
] ]
[[package]] [[package]]
name = "axum-extra" name = "axum-extra"
version = "0.9.6" version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c794b30c904f0a1c2fb7740f7df7f7972dfaa14ef6f57cb6178dc63e5dca2f04" checksum = "45bf463831f5131b7d3c756525b305d40f1185b688565648a92e1392ca35713d"
dependencies = [ dependencies = [
"axum", "axum 0.8.4",
"axum-core", "axum-core 0.5.2",
"bytes", "bytes",
"fastrand",
"futures-util", "futures-util",
"headers", "headers",
"http", "http",
"http-body", "http-body",
"http-body-util", "http-body-util",
"mime", "mime",
"multer",
"pin-project-lite", "pin-project-lite",
"rustversion",
"serde", "serde",
"tower 0.5.2", "tower 0.5.2",
"tower-layer", "tower-layer",
@ -660,15 +705,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
[[package]]
name = "encoding_rs"
version = "0.8.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
dependencies = [
"cfg-if",
]
[[package]] [[package]]
name = "enum-as-inner" name = "enum-as-inner"
version = "0.6.1" version = "0.6.1"
@ -916,7 +952,7 @@ dependencies = [
"argon2", "argon2",
"assert_cmd", "assert_cmd",
"async-trait", "async-trait",
"axum", "axum 0.8.4",
"axum-extra", "axum-extra",
"axum-server", "axum-server",
"base64 0.22.1", "base64 0.22.1",
@ -1660,6 +1696,12 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
[[package]]
name = "matchit"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.7.4" version = "2.7.4"
@ -1699,23 +1741,6 @@ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "multer"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b"
dependencies = [
"bytes",
"encoding_rs",
"futures-util",
"http",
"httparse",
"memchr",
"mime",
"spin",
"version_check",
]
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.29.0" version = "0.29.0"
@ -3094,12 +3119,6 @@ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "spin"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]] [[package]]
name = "spki" name = "spki"
version = "0.7.3" version = "0.7.3"
@ -3455,7 +3474,7 @@ checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"async-trait", "async-trait",
"axum", "axum 0.7.9",
"base64 0.22.1", "base64 0.22.1",
"bytes", "bytes",
"h2", "h2",

View file

@ -90,8 +90,8 @@ workspace = true
[dependencies] [dependencies]
argon2 = "0.5.3" argon2 = "0.5.3"
async-trait = "0.1.88" async-trait = "0.1.88"
axum = { version = "0.7.9", default-features = false, features = ["form", "http1", "http2", "json", "matched-path", "tokio", "tracing"] } axum = { version = "0.8.4", default-features = false, features = ["form", "http1", "http2", "json", "matched-path", "tokio", "tracing"] }
axum-extra = { version = "0.9.5", features = ["typed-header"] } axum-extra = { version = "0.10.1", features = ["typed-header"] }
axum-server = { git = "https://gitlab.computer.surgery/matrix/thirdparty/axum-server.git", rev = "v0.7.2+grapevine-1", version = "0.7.2", features = ["tls-rustls-no-provider"] } axum-server = { git = "https://gitlab.computer.surgery/matrix/thirdparty/axum-server.git", rev = "v0.7.2+grapevine-1", version = "0.7.2", features = ["tls-rustls-no-provider"] }
base64 = "0.22.1" base64 = "0.22.1"
bytes = "1.10.1" bytes = "1.10.1"

View file

@ -1,7 +1,6 @@
use std::{collections::BTreeMap, iter::FromIterator, str}; use std::{collections::BTreeMap, iter::FromIterator, str};
use axum::{ use axum::{
async_trait,
body::Body, body::Body,
extract::{FromRequest, Path}, extract::{FromRequest, Path},
response::{IntoResponse, Response}, response::{IntoResponse, Response},
@ -398,10 +397,10 @@ async fn ar_from_request_inner(
}) })
} }
#[async_trait]
impl<T, S> FromRequest<S> for Ar<T> impl<T, S> FromRequest<S> for Ar<T>
where where
T: IncomingRequest, T: IncomingRequest,
S: Sync,
{ {
type Rejection = Error; type Rejection = Error;

View file

@ -209,13 +209,14 @@ struct ServerSpawner<'cfg, M> {
impl<'cfg, M> ServerSpawner<'cfg, M> impl<'cfg, M> ServerSpawner<'cfg, M>
where where
M: Layer<Route> + Clone + Send + 'static, M: Layer<Route> + Clone + Send + Sync + 'static,
M::Service: Service< M::Service: Service<
axum::extract::Request, axum::extract::Request,
Response = axum::response::Response, Response = axum::response::Response,
Error = Infallible, Error = Infallible,
> + Clone > + Clone
+ Send + Send
+ Sync
+ 'static, + 'static,
<M::Service as Service<axum::extract::Request>>::Future: Send + 'static, <M::Service as Service<axum::extract::Request>>::Future: Send + 'static,
{ {
@ -929,14 +930,13 @@ pub(crate) trait RumaHandler<T> {
macro_rules! impl_ruma_handler { macro_rules! impl_ruma_handler {
( $($ty:ident),* $(,)? ) => { ( $($ty:ident),* $(,)? ) => {
#[axum::async_trait]
#[allow(non_snake_case)] #[allow(non_snake_case)]
impl<Req, Resp, E, F, Fut, $($ty,)*> impl<Req, Resp, E, F, Fut, $($ty,)*>
RumaHandler<($($ty,)* Ar<Req>,)> for F RumaHandler<($($ty,)* Ar<Req>,)> for F
where where
Req: IncomingRequest + Send + 'static, Req: IncomingRequest + Send + 'static,
Resp: IntoResponse, Resp: IntoResponse,
F: FnOnce($($ty,)* Ar<Req>) -> Fut + Clone + Send + 'static, F: FnOnce($($ty,)* Ar<Req>) -> Fut + Clone + Send + Sync + 'static,
Fut: Future<Output = Result<Resp, E>> Fut: Future<Output = Result<Resp, E>>
+ Send, + Send,
E: IntoResponse, E: IntoResponse,

View file

@ -1,5 +1,6 @@
use std::convert::Infallible; use std::convert::Infallible;
use axum_extra::typed_header::TypedHeaderRejection;
use http::StatusCode; use http::StatusCode;
use ruma::{ use ruma::{
api::client::{ api::client::{
@ -51,6 +52,11 @@ pub(crate) enum Error {
#[from] #[from]
source: regex::Error, source: regex::Error,
}, },
#[error("Invalid header value: {source}")]
InvalidHeaderValue {
#[from]
source: TypedHeaderRejection,
},
#[error("{0}")] #[error("{0}")]
Federation(OwnedServerName, RumaError), Federation(OwnedServerName, RumaError),
#[error("Could not do this io: {source}")] #[error("Could not do this io: {source}")]