From 6ec3a51f2dfb989f19c7ba7d5afe48b36c893a3b Mon Sep 17 00:00:00 2001 From: Sabrina Jewson Date: Sun, 22 Sep 2024 12:32:59 +0100 Subject: [PATCH 1/5] Clarify some subtleties of routing (#2896) --- axum/src/docs/routing/fallback.md | 6 +++++- axum/src/docs/routing/nest.md | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/axum/src/docs/routing/fallback.md b/axum/src/docs/routing/fallback.md index 27fb76a5..a864b7a4 100644 --- a/axum/src/docs/routing/fallback.md +++ b/axum/src/docs/routing/fallback.md @@ -23,7 +23,11 @@ async fn fallback(uri: Uri) -> (StatusCode, String) { Fallbacks only apply to routes that aren't matched by anything in the router. If a handler is matched by a request but returns 404 the -fallback is not called. +fallback is not called. Note that this applies to [`MethodRouter`]s too: if the +request hits a valid path but the [`MethodRouter`] does not have an appropriate +method handler installed, the fallback is not called (use +[`MethodRouter::fallback`] for this purpose instead). + # Handling all requests without other routes diff --git a/axum/src/docs/routing/nest.md b/axum/src/docs/routing/nest.md index 3151729e..845072f0 100644 --- a/axum/src/docs/routing/nest.md +++ b/axum/src/docs/routing/nest.md @@ -82,6 +82,11 @@ let app = Router::new() # let _: Router = app; ``` +Additionally, while the wildcard route `/foo/*rest` will not match the +paths `/foo` or `/foo/`, a nested router at `/foo` will match the path `/foo` +(but not `/foo/`), and a nested router at `/foo/` will match the path `/foo/` +(but not `/foo`). + # Fallbacks If a nested router doesn't have its own fallback then it will inherit the From 4fc0641874fa73d34b64b89e715937498eaec0ee Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 24 Sep 2024 21:50:53 +0000 Subject: [PATCH 2/5] Upgrade private dependencies (#2935) --- axum/Cargo.toml | 6 +++--- examples/http-proxy/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/axum/Cargo.toml b/axum/Cargo.toml index 4ef57819..b4cd4363 100644 --- a/axum/Cargo.toml +++ b/axum/Cargo.toml @@ -63,7 +63,7 @@ tower-service = "0.3" # optional dependencies axum-macros = { path = "../axum-macros", version = "0.4.2", optional = true } -base64 = { version = "0.21.0", optional = true } +base64 = { version = "0.22.1", optional = true } hyper = { version = "1.1.0", optional = true } hyper-util = { version = "0.1.3", features = ["tokio", "server", "service"], optional = true } multer = { version = "3.0.0", optional = true } @@ -72,7 +72,7 @@ serde_path_to_error = { version = "0.1.8", optional = true } serde_urlencoded = { version = "0.7", optional = true } sha1 = { version = "0.10", optional = true } tokio = { package = "tokio", version = "1.25.0", features = ["time"], optional = true } -tokio-tungstenite = { version = "0.23", optional = true } +tokio-tungstenite = { version = "0.24.0", optional = true } tracing = { version = "0.1", default-features = false, optional = true } [dependencies.tower-http] @@ -121,7 +121,7 @@ serde_json = "1.0" time = { version = "0.3", features = ["serde-human-readable"] } tokio = { package = "tokio", version = "1.25.0", features = ["macros", "rt", "rt-multi-thread", "net", "test-util"] } tokio-stream = "0.1" -tokio-tungstenite = "0.23" +tokio-tungstenite = "0.24.0" tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["json"] } uuid = { version = "1.0", features = ["serde", "v4"] } diff --git a/examples/http-proxy/Cargo.toml b/examples/http-proxy/Cargo.toml index aa607002..63854471 100644 --- a/examples/http-proxy/Cargo.toml +++ b/examples/http-proxy/Cargo.toml @@ -9,6 +9,6 @@ axum = { path = "../../axum" } hyper = { version = "1", features = ["full"] } hyper-util = "0.1.1" tokio = { version = "1.0", features = ["full"] } -tower = { version = "0.4", features = ["make"] } +tower = { version = "0.4", features = ["make", "util"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } From 6f5607785d2dc7ea0ede03c11914d32cdb305953 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 25 Sep 2024 07:44:35 +0000 Subject: [PATCH 3/5] core: Fix compile errors from __log_rejection (#2933) --- axum-core/src/lib.rs | 5 +++++ axum-core/src/macros.rs | 6 +++--- axum-extra/Cargo.toml | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/axum-core/src/lib.rs b/axum-core/src/lib.rs index cd1dc2ee..134c566b 100644 --- a/axum-core/src/lib.rs +++ b/axum-core/src/lib.rs @@ -50,6 +50,11 @@ #[macro_use] pub(crate) mod macros; +#[doc(hidden)] // macro helpers +pub mod __private { + #[cfg(feature = "tracing")] + pub use tracing; +} mod error; mod ext_traits; diff --git a/axum-core/src/macros.rs b/axum-core/src/macros.rs index 7d723818..aa99ba40 100644 --- a/axum-core/src/macros.rs +++ b/axum-core/src/macros.rs @@ -9,12 +9,12 @@ macro_rules! __log_rejection { status = $status:expr, ) => { { - tracing::event!( + $crate::__private::tracing::event!( target: "axum::rejection", - tracing::Level::TRACE, + $crate::__private::tracing::Level::TRACE, status = $status.as_u16(), body = $body_text, - rejection_type = std::any::type_name::<$ty>(), + rejection_type = ::std::any::type_name::<$ty>(), "rejecting request", ); } diff --git a/axum-extra/Cargo.toml b/axum-extra/Cargo.toml index 06aa0766..7a964b00 100644 --- a/axum-extra/Cargo.toml +++ b/axum-extra/Cargo.toml @@ -34,7 +34,7 @@ json-lines = [ multipart = ["dep:multer"] protobuf = ["dep:prost"] query = ["dep:serde_html_form"] -tracing = ["dep:tracing", "axum-core/tracing", "axum/tracing"] +tracing = ["axum-core/tracing", "axum/tracing"] typed-header = ["dep:headers"] typed-routing = ["dep:axum-macros", "dep:percent-encoding", "dep:serde_html_form", "dep:form_urlencoded"] From ac50d7daafad8e0afd206d5aeaca5e33851dc57b Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 27 Sep 2024 19:16:17 +0000 Subject: [PATCH 4/5] docs: Remove manual tables of content (#2921) --- axum/CHANGELOG.md | 7 +++++++ axum/src/docs/error_handling.md | 7 ------- axum/src/docs/extract.md | 15 --------------- axum/src/docs/middleware.md | 12 ------------ axum/src/docs/response.md | 6 ------ axum/src/lib.rs | 17 ----------------- 6 files changed, 7 insertions(+), 57 deletions(-) diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md index 0379672c..acab31cc 100644 --- a/axum/CHANGELOG.md +++ b/axum/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# Unreleased + +- **change**: Remove manual tables of content from the documentation, since + rustdoc now generates tables of content in the sidebar ([#2921]) + +[#2921]: https://github.com/tokio-rs/axum/pull/2921 + # 0.7.6 - **change:** Avoid cloning `Arc` during deserialization of `Path` diff --git a/axum/src/docs/error_handling.md b/axum/src/docs/error_handling.md index 6993b29a..7d7e14ee 100644 --- a/axum/src/docs/error_handling.md +++ b/axum/src/docs/error_handling.md @@ -1,12 +1,5 @@ Error handling model and utilities -# Table of contents - -- [axum's error handling model](#axums-error-handling-model) -- [Routing to fallible services](#routing-to-fallible-services) -- [Applying fallible middleware](#applying-fallible-middleware) -- [Running extractors for error handling](#running-extractors-for-error-handling) - # axum's error handling model axum is based on [`tower::Service`] which bundles errors through its associated diff --git a/axum/src/docs/extract.md b/axum/src/docs/extract.md index 0389ca3c..a1710958 100644 --- a/axum/src/docs/extract.md +++ b/axum/src/docs/extract.md @@ -1,20 +1,5 @@ Types and traits for extracting data from requests. -# Table of contents - -- [Intro](#intro) -- [Common extractors](#common-extractors) -- [Applying multiple extractors](#applying-multiple-extractors) -- [The order of extractors](#the-order-of-extractors) -- [Optional extractors](#optional-extractors) -- [Customizing extractor responses](#customizing-extractor-responses) -- [Accessing inner errors](#accessing-inner-errors) -- [Defining custom extractors](#defining-custom-extractors) -- [Accessing other extractors in `FromRequest` or `FromRequestParts` implementations](#accessing-other-extractors-in-fromrequest-or-fromrequestparts-implementations) -- [Request body limits](#request-body-limits) -- [Wrapping extractors](#wrapping-extractors) -- [Logging rejections](#logging-rejections) - # Intro A handler function is an async function that takes any number of diff --git a/axum/src/docs/middleware.md b/axum/src/docs/middleware.md index 85731414..3a902372 100644 --- a/axum/src/docs/middleware.md +++ b/axum/src/docs/middleware.md @@ -1,15 +1,3 @@ -# Table of contents - -- [Intro](#intro) -- [Applying middleware](#applying-middleware) -- [Commonly used middleware](#commonly-used-middleware) -- [Ordering](#ordering) -- [Writing middleware](#writing-middleware) -- [Routing to services/middleware and backpressure](#routing-to-servicesmiddleware-and-backpressure) -- [Accessing state in middleware](#accessing-state-in-middleware) -- [Passing state from middleware to handlers](#passing-state-from-middleware-to-handlers) -- [Rewriting request URI in middleware](#rewriting-request-uri-in-middleware) - # Intro axum is unique in that it doesn't have its own bespoke middleware system and diff --git a/axum/src/docs/response.md b/axum/src/docs/response.md index 67695632..c0974fb6 100644 --- a/axum/src/docs/response.md +++ b/axum/src/docs/response.md @@ -1,11 +1,5 @@ Types and traits for generating responses. -# Table of contents - -- [Building responses](#building-responses) -- [Returning different response types](#returning-different-response-types) -- [Regarding `impl IntoResponse`](#regarding-impl-intoresponse) - # Building responses Anything that implements [`IntoResponse`] can be returned from a handler. axum diff --git a/axum/src/lib.rs b/axum/src/lib.rs index 7d0d3802..29796229 100644 --- a/axum/src/lib.rs +++ b/axum/src/lib.rs @@ -1,22 +1,5 @@ //! axum is a web application framework that focuses on ergonomics and modularity. //! -//! # Table of contents -//! -//! - [High-level features](#high-level-features) -//! - [Compatibility](#compatibility) -//! - [Example](#example) -//! - [Routing](#routing) -//! - [Handlers](#handlers) -//! - [Extractors](#extractors) -//! - [Responses](#responses) -//! - [Error handling](#error-handling) -//! - [Middleware](#middleware) -//! - [Sharing state with handlers](#sharing-state-with-handlers) -//! - [Building integrations for axum](#building-integrations-for-axum) -//! - [Required dependencies](#required-dependencies) -//! - [Examples](#examples) -//! - [Feature flags](#feature-flags) -//! //! # High-level features //! //! - Route requests to handlers with a macro-free API. From fe56a310efbb30b3b178059c48a31d1000ed5f62 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 27 Sep 2024 21:30:11 +0200 Subject: [PATCH 5/5] Bump versions --- axum-core/CHANGELOG.md | 7 +++++++ axum-core/Cargo.toml | 2 +- axum-extra/Cargo.toml | 4 ++-- axum/CHANGELOG.md | 2 +- axum/Cargo.toml | 4 ++-- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/axum-core/CHANGELOG.md b/axum-core/CHANGELOG.md index 464ee314..dc1b9ed5 100644 --- a/axum-core/CHANGELOG.md +++ b/axum-core/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# 0.4.5 + +- **fixed:** Compile errors from the internal `__log_rejection` macro under + certain Cargo feature combinations between axum crates ([#2933]) + +[#2933]: https://github.com/tokio-rs/axum/pull/2933 + # 0.4.4 - **added:** Derive `Clone` and `Copy` for `AppendHeaders` ([#2776]) diff --git a/axum-core/Cargo.toml b/axum-core/Cargo.toml index 2d4d0759..f7c31668 100644 --- a/axum-core/Cargo.toml +++ b/axum-core/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" name = "axum-core" readme = "README.md" repository = "https://github.com/tokio-rs/axum" -version = "0.4.4" # remember to also bump the version that axum and axum-extra depend on +version = "0.4.5" # remember to also bump the version that axum and axum-extra depend on [features] tracing = ["dep:tracing"] diff --git a/axum-extra/Cargo.toml b/axum-extra/Cargo.toml index 7a964b00..7c967749 100644 --- a/axum-extra/Cargo.toml +++ b/axum-extra/Cargo.toml @@ -39,8 +39,8 @@ typed-header = ["dep:headers"] typed-routing = ["dep:axum-macros", "dep:percent-encoding", "dep:serde_html_form", "dep:form_urlencoded"] [dependencies] -axum = { path = "../axum", version = "0.7.6", default-features = false } -axum-core = { path = "../axum-core", version = "0.4.4" } +axum = { path = "../axum", version = "0.7.7", default-features = false } +axum-core = { path = "../axum-core", version = "0.4.5" } bytes = "1.1.0" futures-util = { version = "0.3", default-features = false, features = ["alloc"] } http = "1.0.0" diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md index acab31cc..aa9d8067 100644 --- a/axum/CHANGELOG.md +++ b/axum/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -# Unreleased +# 0.7.7 - **change**: Remove manual tables of content from the documentation, since rustdoc now generates tables of content in the sidebar ([#2921]) diff --git a/axum/Cargo.toml b/axum/Cargo.toml index b4cd4363..263d3a96 100644 --- a/axum/Cargo.toml +++ b/axum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "axum" -version = "0.7.6" +version = "0.7.7" categories = ["asynchronous", "network-programming", "web-programming::http-server"] description = "Web framework that focuses on ergonomics and modularity" edition = "2021" @@ -42,7 +42,7 @@ __private_docs = ["tower/full", "dep:tower-http"] [dependencies] async-trait = "0.1.67" -axum-core = { path = "../axum-core", version = "0.4.4" } +axum-core = { path = "../axum-core", version = "0.4.5" } bytes = "1.0" futures-util = { version = "0.3", default-features = false, features = ["alloc"] } http = "1.0.0"