Compare commits

...

3 Commits

Author SHA1 Message Date
Cyandev
3427cf0f02
Merge 7f611b2ad9 into 0dc7a055a9 2026-02-05 10:56:27 -05:00
Canmi
0dc7a055a9
fix: empty_enum renamed to empty_enums (#3642) 2026-02-04 07:34:35 +01:00
Cyandev
7f611b2ad9
docs: Refine the example comments for Router::route_service() 2025-07-16 23:58:30 +08:00
2 changed files with 6 additions and 6 deletions

View File

@ -18,7 +18,7 @@ type_complexity = "allow"
await_holding_lock = "warn" await_holding_lock = "warn"
dbg_macro = "warn" dbg_macro = "warn"
empty_enum = "warn" empty_enums = "warn"
enum_glob_use = "warn" enum_glob_use = "warn"
equatable_if_let = "warn" equatable_if_let = "warn"
exit = "warn" exit = "warn"

View File

@ -20,9 +20,9 @@ let app = Router::new()
.route( .route(
// Any request to `/` goes to a service // Any request to `/` goes to a service
"/", "/",
// Services whose response body is not `axum::body::BoxBody` // Services whose responses implement `axum::response::IntoResponse` can
// can be wrapped in `axum::routing::any_service` (or one of the other routing filters) // be wrapped in `axum::routing::any_service` (or one of the other routing filters)
// to have the response body mapped // to turn them into routes.
any_service(service_fn(|_: Request| async { any_service(service_fn(|_: Request| async {
let res = Response::new(Body::from("Hi from `GET /`")); let res = Response::new(Body::from("Hi from `GET /`"));
Ok::<_, Infallible>(res) Ok::<_, Infallible>(res)
@ -30,8 +30,8 @@ let app = Router::new()
) )
.route_service( .route_service(
"/foo", "/foo",
// This service's response body is `axum::body::BoxBody` so // This service's request body is `axum::body::Body`, and its response
// it can be routed to directly. // can be any type that implements `axum::response::IntoResponse`.
service_fn(|req: Request| async move { service_fn(|req: Request| async move {
let body = Body::from(format!("Hi from `{} /foo`", req.method())); let body = Body::from(format!("Hi from `{} /foo`", req.method()));
let res = Response::new(body); let res = Response::new(body);