diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8d3932c2..53ffe259 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/axum-core/src/extract/default_body_limit.rs b/axum-core/src/extract/default_body_limit.rs index bb1f44bf..f112c341 100644 --- a/axum-core/src/extract/default_body_limit.rs +++ b/axum-core/src/extract/default_body_limit.rs @@ -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. /// diff --git a/axum-core/src/extract/rejection.rs b/axum-core/src/extract/rejection.rs index c5c3b1db..ef71cae5 100644 --- a/axum-core/src/extract/rejection.rs +++ b/axum-core/src/extract/rejection.rs @@ -20,7 +20,7 @@ impl FailedToBufferBody { E: Into, { // 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::() { Ok(err) => err.into_inner(), diff --git a/axum-extra/src/extract/cached.rs b/axum-extra/src/extract/cached.rs index 0b299d2b..c6fdb59e 100644 --- a/axum-extra/src/extract/cached.rs +++ b/axum-extra/src/extract/cached.rs @@ -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` 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::::from_request_parts(parts, state) /// .await /// .map_err(|err| err.into_response())? diff --git a/axum-extra/src/extract/cookie/private.rs b/axum-extra/src/extract/cookie/private.rs index a5a7cd74..3be4ff95 100644 --- a/axum-extra/src/extract/cookie/private.rs +++ b/axum-extra/src/extract/cookie/private.rs @@ -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 diff --git a/axum-extra/src/handler/mod.rs b/axum-extra/src/handler/mod.rs index c4aa3825..18c22456 100644 --- a/axum-extra/src/handler/mod.rs +++ b/axum-extra/src/handler/mod.rs @@ -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: Sized { /// The type of future calling this handler returns. diff --git a/axum-extra/src/response/multiple.rs b/axum-extra/src/response/multiple.rs index a9d674dc..1d5f0cb5 100644 --- a/axum-extra/src/response/multiple.rs +++ b/axum-extra/src/response/multiple.rs @@ -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 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); diff --git a/axum-macros/src/debug_handler.rs b/axum-macros/src/debug_handler.rs index c4838d56..4d44b070 100644 --- a/axum-macros/src/debug_handler.rs +++ b/axum-macros/src/debug_handler.rs @@ -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"); }; } } diff --git a/axum-macros/tests/debug_middleware/fail/next_not_last.stderr b/axum-macros/tests/debug_middleware/fail/next_not_last.stderr index 4a5fea45..3b85fc9e 100644 --- a/axum-macros/tests/debug_middleware/fail/next_not_last.stderr +++ b/axum-macros/tests/debug_middleware/fail/next_not_last.stderr @@ -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 { diff --git a/axum/src/docs/extract.md b/axum/src/docs/extract.md index f65b55a8..6c1acb13 100644 --- a/axum/src/docs/extract.md +++ b/axum/src/docs/extract.md @@ -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` 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`]. diff --git a/axum/src/docs/method_routing/fallback.md b/axum/src/docs/method_routing/fallback.md index ec78f201..4c1cf41f 100644 --- a/axum/src/docs/method_routing/fallback.md +++ b/axum/src/docs/method_routing/fallback.md @@ -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::{ diff --git a/axum/src/docs/method_routing/route_layer.md b/axum/src/docs/method_routing/route_layer.md index b045d100..51fcfc22 100644 --- a/axum/src/docs/method_routing/route_layer.md +++ b/axum/src/docs/method_routing/route_layer.md @@ -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; ``` diff --git a/axum/src/docs/middleware.md b/axum/src/docs/middleware.md index f7184910..9effdf3e 100644 --- a/axum/src/docs/middleware.md +++ b/axum/src/docs/middleware.md @@ -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... diff --git a/axum/src/docs/response.md b/axum/src/docs/response.md index c0974fb6..1b661ceb 100644 --- a/axum/src/docs/response.md +++ b/axum/src/docs/response.md @@ -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 { 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> { Json(vec!["foo".to_owned(), "bar".to_owned()]) diff --git a/axum/src/docs/routing/fallback.md b/axum/src/docs/routing/fallback.md index 8f1dab63..2f54f64d 100644 --- a/axum/src/docs/routing/fallback.md +++ b/axum/src/docs/routing/fallback.md @@ -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 diff --git a/axum/src/docs/routing/route_layer.md b/axum/src/docs/routing/route_layer.md index 9cce3ea7..4bb48847 100644 --- a/axum/src/docs/routing/route_layer.md +++ b/axum/src/docs/routing/route_layer.md @@ -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; ``` diff --git a/axum/src/docs/routing/with_state.md b/axum/src/docs/routing/with_state.md index eda2344b..ac7ad867 100644 --- a/axum/src/docs/routing/with_state.md +++ b/axum/src/docs/routing/with_state.md @@ -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 = Router::new() // Here we pick `String`. let string_router: Router = 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| async {})); diff --git a/axum/src/lib.rs b/axum/src/lib.rs index 3e3b4bd5..3216d48a 100644 --- a/axum/src/lib.rs +++ b/axum/src/lib.rs @@ -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) diff --git a/axum/src/response/sse.rs b/axum/src/response/sse.rs index cb289219..75805d28 100644 --- a/axum/src/response/sse.rs +++ b/axum/src/response/sse.rs @@ -221,7 +221,7 @@ impl Event { } } - /// Set the event's data data field(s) (`data: `) + /// Set the event's data field(s) (`data: `) /// /// Newlines in `data` will automatically be broken across `data: ` fields. /// diff --git a/examples/README.md b/examples/README.md index 565c1796..a20579e6 100644 --- a/examples/README.md +++ b/examples/README.md @@ -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). diff --git a/examples/consume-body-in-extractor-or-middleware/src/main.rs b/examples/consume-body-in-extractor-or-middleware/src/main.rs index 358f4b60..59cfd3a3 100644 --- a/examples/consume-body-in-extractor-or-middleware/src/main.rs +++ b/examples/consume-body-in-extractor-or-middleware/src/main.rs @@ -49,7 +49,7 @@ async fn print_request_body(request: Request, next: Next) -> Result Result { 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 diff --git a/examples/customize-extractor-error/src/with_rejection.rs b/examples/customize-extractor-error/src/with_rejection.rs index 1916c369..6b8b1ffe 100644 --- a/examples/customize-extractor-error/src/with_rejection.rs +++ b/examples/customize-extractor-error/src/with_rejection.rs @@ -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 diff --git a/examples/oauth/src/main.rs b/examples/oauth/src/main.rs index 91549347..0e35e4b6 100644 --- a/examples/oauth/src/main.rs +++ b/examples/oauth/src/main.rs @@ -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 diff --git a/examples/testing-websockets/src/main.rs b/examples/testing-websockets/src/main.rs index 885fe44b..bf2af908 100644 --- a/examples/testing-websockets/src/main.rs +++ b/examples/testing-websockets/src/main.rs @@ -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(mut write: W, mut read: R) where diff --git a/examples/websockets/src/main.rs b/examples/websockets/src/main.rs index 73e2df68..f6c71388 100644 --- a/examples/websockets/src/main.rs +++ b/examples/websockets/src/main.rs @@ -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]