-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
T-docsTopic: documentationTopic: documentation
Description
The current documentation for axum::Router::route_service()
has an example that contains the following lines:
// 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
any_service(service_fn(|_: Request| async {
let res = Response::new(Body::from("Hi from `GET /`"));
Ok::<_, Infallible>(res)
}))
...
// This service's response body is `axum::body::BoxBody` so
// it can be routed to directly.
service_fn(|req: Request| async move {
let body = Body::from(format!("Hi from `{} /foo`", req.method()));
let res = Response::new(body);
Ok::<_, Infallible>(res)
})
However, despite what the comments in the code say, both responses appear to have axum::body::Body
as their bodies, and there is currently no axum::body::BoxBody
in the crate. I assume that BoxBody
was removed in an earlier version and the example was only partially updated, but that just raises the question: What is any_service()
good for now?
Metadata
Metadata
Assignees
Labels
T-docsTopic: documentationTopic: documentation