chore: fix typos (#3758)

This commit is contained in:
David Pedersen
2026-05-15 12:32:46 +00:00
committed by GitHub
parent c8276951b0
commit 5bc0046084
25 changed files with 39 additions and 39 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ describes the _minimum_ behavior expected from all contributors.
For any issue, there are fundamentally three ways an individual can contribute:
1. By opening the issue for discussion: For instance, if you believe that you
have uncovered a bug in a `axum` crate, creating a new issue in the
have uncovered a bug in an `axum` crate, creating a new issue in the
tokio-rs/axum [issue tracker][issues] is the way to report it.
2. By helping to triage the issue: This can be done by providing
+1 -1
View File
@@ -5,7 +5,7 @@ use tower_layer::Layer;
/// Layer for configuring the default request body limit.
///
/// For security reasons, [`Bytes`] will, by default, not accept bodies larger than 2MB. This also
/// applies to extractors that uses [`Bytes`] internally such as `String`, [`Json`], and [`Form`].
/// applies to extractors that use [`Bytes`] internally such as `String`, [`Json`], and [`Form`].
///
/// This middleware provides ways to configure that.
///
+1 -1
View File
@@ -20,7 +20,7 @@ impl FailedToBufferBody {
E: Into<BoxError>,
{
// two layers of boxes here because `with_limited_body`
// wraps the `http_body_util::Limited` in a `axum_core::Body`
// wraps the `http_body_util::Limited` in an `axum_core::Body`
// which also wraps the error type
let box_error = match err.into().downcast::<Error>() {
Ok(err) => err.into_inner(),
+2 -2
View File
@@ -8,7 +8,7 @@ use http::request::Parts;
/// This is useful if you have a tree of extractors that share common sub-extractors that
/// you only want to run once, perhaps because they're expensive.
///
/// The cache purely type based so you can only cache one value of each type. The cache is also
/// The cache is purely type-based so you can only cache one value of each type. The cache is also
/// local to the current request and not reused across requests.
///
/// # Example
@@ -48,7 +48,7 @@ use http::request::Parts;
/// // loading a `CurrentUser` requires first loading the `Session`
/// //
/// // by using `Cached<Session>` we avoid extracting the session more than
/// // once, in case other extractors for the same request also loads the session
/// // once, in case other extractors for the same request also load the session
/// let session: Session = Cached::<Session>::from_request_parts(parts, state)
/// .await
/// .map_err(|err| err.into_response())?
+1 -1
View File
@@ -150,7 +150,7 @@ impl PrivateCookieJar {
///
/// The valid cookies in `headers` will be added to the jar.
///
/// This is intended to be used in middleware and other where places it might be difficult to
/// This is intended to be used in middleware and other places where it might be difficult to
/// run extractors. Normally you should create `PrivateCookieJar`s through [`FromRequestParts`].
///
/// [`FromRequestParts`]: axum::extract::FromRequestParts
+1 -1
View File
@@ -20,7 +20,7 @@ pub use self::or::Or;
/// This trait is similar to [`Handler`] but rather than taking the request it takes the extracted
/// inputs.
///
/// The drawbacks of this trait is that you cannot apply middleware to individual handlers like you
/// The drawback of this trait is that you cannot apply middleware to individual handlers like you
/// can with [`Handler::layer`].
pub trait HandlerCallWithExtractors<T, S>: Sized {
/// The type of future calling this handler returns.
+3 -3
View File
@@ -77,7 +77,7 @@ pub struct Part {
// Handling for non-ascii field names is not done here, support for non-ascii characters may be encoded using
// methodology described in RFC 2047.
// - (optionally) a `Content-Type` header, which if not set, defaults to `text/plain`.
// If the field contains a file, then the file should be identified with that file's MIME type (eg: `image/gif`).
// If the field contains a file, then the file should be identified with that file's MIME type (e.g., `image/gif`).
// If the `MIME` type is not known or specified, then the MIME type should be set to `application/octet-stream`.
/// The name of the part in question
name: String,
@@ -209,10 +209,10 @@ impl FromIterator<Part> for MultipartForm {
}
}
/// A boundary is defined as a user defined (arbitrary) value that does not occur in any of the data.
/// A boundary is defined as a user-defined (arbitrary) value that does not occur in any of the data.
///
/// Because the specification does not clearly define a methodology for generating boundaries, this implementation
/// follow's Reqwest's, and generates a boundary in the format of `XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX` where `XXXXXXXX`
/// follows Reqwest's, and generates a boundary in the format of `XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX` where `XXXXXXXX`
/// is a hexadecimal representation of a pseudo randomly generated u64.
fn generate_boundary() -> String {
let a = fastrand::u64(0..u64::MAX);
+1 -1
View File
@@ -844,7 +844,7 @@ fn next_is_last_input(item_fn: &ItemFn) -> TokenStream {
let (idx, arg) = &next_args[0];
if *idx != item_fn.sig.inputs.len() - 1 {
return quote_spanned! {arg.span()=>
compile_error!("`axum::middleware::Next` must the last argument");
compile_error!("`axum::middleware::Next` must be the last argument");
};
}
}
@@ -1,4 +1,4 @@
error: `axum::middleware::Next` must the last argument
error: `axum::middleware::Next` must be the last argument
--> tests/debug_middleware/fail/next_not_last.rs:4:24
|
4 | async fn my_middleware(next: Next, request: Request) -> Response {
+2 -2
View File
@@ -266,7 +266,7 @@ let app = Router::new().route("/foo", post(foo));
# Customizing extractor responses
If an extractor fails it will return a response with the error and your
handler will not be called. To customize the error response you have two
handler will not be called. To customize the error response you have two
options:
1. Use `Result<T, T::Rejection>` as your extractor like shown in
@@ -599,7 +599,7 @@ let app = Router::new().route("/", get(handler)).layer(Extension(state));
# Request body limits
For security reasons, [`Bytes`] will, by default, not accept bodies larger than
2MB. This also applies to extractors that uses [`Bytes`] internally such as
2MB. This also applies to extractors that use [`Bytes`] internally such as
`String`, [`Json`], and [`Form`].
For more details, including how to disable this limit, see [`DefaultBodyLimit`].
+1 -1
View File
@@ -1,6 +1,6 @@
Add a fallback service to the router.
This service will be called if no routes matches the incoming request.
This service will be called if no route matches the incoming request.
```rust
use axum::{
+3 -3
View File
@@ -6,7 +6,7 @@ afterwards. Additional routes added after `route_layer` is called will not have
the middleware added.
This works similarly to [`MethodRouter::layer`] except the middleware will only run if
the request matches a route. This is useful for middleware that return early
the request matches a route. This is useful for middleware that returns early
(such as authorization) which might otherwise convert a `405 Method Not Allowed` into a
`401 Unauthorized`.
@@ -26,7 +26,7 @@ let app = Router::new().route(
);
// `GET /foo` with a valid token will receive `200 OK`
// `GET /foo` with a invalid token will receive `401 Unauthorized`
// `POST /FOO` with a invalid token will receive `405 Method Not Allowed`
// `GET /foo` with an invalid token will receive `401 Unauthorized`
// `POST /FOO` with an invalid token will receive `405 Method Not Allowed`
# let _: Router = app;
```
+1 -1
View File
@@ -326,7 +326,7 @@ handling model.
# Routing to services/middleware and backpressure
Generally routing to one of multiple services and backpressure doesn't mix
well. Ideally you would want ensure a service is ready to receive a request
well. Ideally you would want to ensure a service is ready to receive a request
before calling it. However, in order to know which service to call, you need
the request...
+2 -2
View File
@@ -20,12 +20,12 @@ async fn plain_text(uri: Uri) -> String {
format!("Hi from {}", uri.path())
}
// Bytes will get a `application/octet-stream` content-type
// Bytes will get an `application/octet-stream` content-type
async fn bytes() -> Vec<u8> {
vec![1, 2, 3, 4]
}
// `Json` will get a `application/json` content-type and work with anything that
// `Json` will get an `application/json` content-type and work with anything that
// implements `serde::Serialize`
async fn json() -> Json<Vec<String>> {
Json(vec!["foo".to_owned(), "bar".to_owned()])
+2 -2
View File
@@ -1,6 +1,6 @@
Add a fallback [`Handler`] to the router.
This service will be called if no routes matches the incoming request.
This service will be called if no route matches the incoming request.
```rust
use axum::{
@@ -31,7 +31,7 @@ method handler installed, the fallback is not called (use
# Handling all requests without other routes
Using `Router::new().fallback(...)` to accept all request regardless of path or
Using `Router::new().fallback(...)` to accept all requests regardless of path or
method, if you don't have other routes, isn't optimal:
```rust
+3 -3
View File
@@ -7,7 +7,7 @@ afterwards. Additional routes added after `route_layer` is called will not have
the middleware added.
This works similarly to [`Router::layer`] except the middleware will only run if
the request matches a route. This is useful for middleware that return early
the request matches a route. This is useful for middleware that returns early
(such as authorization) which might otherwise convert a `404 Not Found` into a
`401 Unauthorized`.
@@ -29,7 +29,7 @@ let app = Router::new()
.route_layer(ValidateRequestHeaderLayer::bearer("password"));
// `GET /foo` with a valid token will receive `200 OK`
// `GET /foo` with a invalid token will receive `401 Unauthorized`
// `GET /not-found` with a invalid token will receive `404 Not Found`
// `GET /foo` with an invalid token will receive `401 Unauthorized`
// `GET /not-found` with an invalid token will receive `404 Not Found`
# let _: Router = app;
```
+2 -2
View File
@@ -135,7 +135,7 @@ axum::serve(listener, router).await;
# };
```
Perhaps a little counter intuitively, `Router::with_state` doesn't always return a
Perhaps a little counterintuitively, `Router::with_state` doesn't always return a
`Router<()>`. Instead you get to pick what the new missing state type is:
```rust
@@ -150,7 +150,7 @@ let router: Router<AppState> = Router::new()
// Here we pick `String`.
let string_router: Router<String> = router.with_state(AppState {});
// That allows us to add new routes that uses `String` as the state type
// That allows us to add new routes that use `String` as the state type
let string_router = string_router
.route("/needs-string", get(|_: State<String>| async {}));
+2 -2
View File
@@ -324,7 +324,7 @@
//!
//! ## Using task-local variables
//!
//! This also allows to share state with `IntoResponse` implementations:
//! This also allows sharing state with `IntoResponse` implementations:
//!
//! ```rust,no_run
//! use axum::{
@@ -352,7 +352,7 @@
//! .and_then(|header| header.to_str().ok())
//! .ok_or(StatusCode::UNAUTHORIZED)?;
//! if let Some(current_user) = authorize_current_user(auth_header).await {
//! // State is setup here in the middleware
//! // State is set up here in the middleware
//! Ok(USER.scope(current_user, next.run(req)).await)
//! } else {
//! Err(StatusCode::UNAUTHORIZED)
+1 -1
View File
@@ -221,7 +221,7 @@ impl Event {
}
}
/// Set the event's data data field(s) (`data: <content>`)
/// Set the event's data field(s) (`data: <content>`)
///
/// Newlines in `data` will automatically be broken across `data: ` fields.
///
+1 -1
View File
@@ -1,7 +1,7 @@
# Examples
This folder contains numerous examples showing how to use axum. Each example is
setup as its own crate so its dependencies are clear.
set up as its own crate so its dependencies are clear.
For a list of what the community built with axum, please see the list
[here](../ECOSYSTEM.md).
@@ -49,7 +49,7 @@ async fn print_request_body(request: Request, next: Next) -> Result<impl IntoRes
async fn buffer_request_body(request: Request) -> Result<Request, Response> {
let (parts, body) = request.into_parts();
// this won't work if the body is an long running stream
// this won't work if the body is a long-running stream
let bytes = body
.collect()
.await
@@ -7,9 +7,9 @@
//! `thiserror` can provide such conversion using derive macros. See
//! [`thiserror`]
//! - Verbose types: types become much larger, which makes them difficult to
//! read. Current limitations on type aliasing makes impossible to destructure
//! read. Current limitations on type aliasing make it impossible to destructure
//! a type alias. See [#1116]
//!
//!
//! [`thiserror`]: https://crates.io/crates/thiserror
//! [#1116]: https://github.com/tokio-rs/axum/issues/1116#issuecomment-1186197684
+1 -1
View File
@@ -277,7 +277,7 @@ async fn login_authorized(
.exchange_code(AuthorizationCode::new(query.code.clone()))
.request_async(&client)
.await
.context("failed in sending request request to authorization server")?;
.context("failed in sending request to authorization server")?;
// Fetch user data from discord
let user_data: User = client
+1 -1
View File
@@ -69,7 +69,7 @@ async fn unit_testable_handler(ws: WebSocketUpgrade) -> Response {
})
}
// The implementation is largely the same as `integration_testable_handle_socket` expect we call
// The implementation is largely the same as `integration_testable_handle_socket` except we call
// methods from `SinkExt` and `StreamExt`.
async fn unit_testable_handle_socket<W, R>(mut write: W, mut read: R)
where
+2 -2
View File
@@ -34,11 +34,11 @@ use tower_http::{
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
//allows to extract the IP of connecting user
// Allows extracting the IP of the connecting user
use axum::extract::connect_info::ConnectInfo;
use axum::extract::ws::CloseFrame;
//allows to split the websocket stream into separate TX and RX branches
// Allows splitting the websocket stream into separate TX and RX branches
use futures_util::{sink::SinkExt, stream::StreamExt};
#[tokio::main]