From 7f611b2ad90b5692fb7f825206aefc8dd80427de Mon Sep 17 00:00:00 2001 From: Cyandev Date: Wed, 16 Jul 2025 23:58:30 +0800 Subject: [PATCH] docs: Refine the example comments for `Router::route_service()` --- axum/src/docs/routing/route_service.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/axum/src/docs/routing/route_service.md b/axum/src/docs/routing/route_service.md index 7f016105df..aa2ded4a1b 100644 --- a/axum/src/docs/routing/route_service.md +++ b/axum/src/docs/routing/route_service.md @@ -20,9 +20,9 @@ let app = Router::new() .route( // Any request to `/` goes to a service "/", - // Services whose response body is not `axum::body::BoxBody` - // can be wrapped in `axum::routing::any_service` (or one of the other routing filters) - // to have the response body mapped + // Services whose responses implement `axum::response::IntoResponse` can + // be wrapped in `axum::routing::any_service` (or one of the other routing filters) + // to turn them into routes. any_service(service_fn(|_: Request| async { let res = Response::new(Body::from("Hi from `GET /`")); Ok::<_, Infallible>(res) @@ -30,8 +30,8 @@ let app = Router::new() ) .route_service( "/foo", - // This service's response body is `axum::body::BoxBody` so - // it can be routed to directly. + // This service's request body is `axum::body::Body`, and its response + // can be any type that implements `axum::response::IntoResponse`. service_fn(|req: Request| async move { let body = Body::from(format!("Hi from `{} /foo`", req.method())); let res = Response::new(body);