mirror of
https://github.com/tokio-rs/axum.git
synced 2026-02-06 11:17:48 +00:00
Compare commits
3 Commits
a357979f2a
...
3427cf0f02
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3427cf0f02 | ||
|
|
0dc7a055a9 | ||
|
|
7f611b2ad9 |
@ -18,7 +18,7 @@ type_complexity = "allow"
|
||||
|
||||
await_holding_lock = "warn"
|
||||
dbg_macro = "warn"
|
||||
empty_enum = "warn"
|
||||
empty_enums = "warn"
|
||||
enum_glob_use = "warn"
|
||||
equatable_if_let = "warn"
|
||||
exit = "warn"
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user