File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,7 @@ use axum::{Router, response::IntoResponse};
31
31
use axum_codec :: {
32
32
response :: IntoCodecResponse ,
33
33
routing :: {get, post},
34
- Codec ,
35
- extract :: Accept ,
34
+ Codec , Accept ,
36
35
};
37
36
38
37
// Shorthand for the following (assuming all features are enabled):
@@ -62,12 +61,12 @@ async fn me() -> Codec<User> {
62
61
}
63
62
64
63
/// A manual implementation of the handler above.
65
- async fn manual_me (accept : Accept , Codec ( user ) : Codec < User > ) -> impl IntoResponse {
64
+ async fn manual_me (accept : Accept ) -> impl IntoResponse {
66
65
Codec (User {
67
66
name : " Alice" . into (),
68
67
age : 42 ,
69
68
})
70
- . into_codec_response (accept . content_type ())
69
+ . into_codec_response (accept . into ())
71
70
}
72
71
73
72
#[axum_codec:: apply(encode)]
@@ -86,7 +85,7 @@ async fn greet(Codec(user): Codec<User>) -> impl IntoCodecResponse {
86
85
async fn main () {
87
86
let app : Router = Router :: new ()
88
87
. route (" /me" , get (me ). into ())
89
- . route (" /manual" , axum :: routing :: post (manual_me ))
88
+ . route (" /manual" , axum :: routing :: get (manual_me ))
90
89
. route (" /greet" , post (greet ). into ());
91
90
92
91
let listener = tokio :: net :: TcpListener :: bind ((" 127.0.0.1" , 3000 ))
You can’t perform that action at this time.
0 commit comments