@@ -22,7 +22,9 @@ use axum::{
22
22
} ,
23
23
handler:: Handler ,
24
24
headers:: { authorization:: Bearer , Authorization , CacheControl , ETag , IfNoneMatch } ,
25
- http:: { header, uri:: PathAndQuery , HeaderValue , Method , Request , StatusCode , Uri } ,
25
+ http:: {
26
+ header, request:: Parts , uri:: PathAndQuery , HeaderValue , Method , Request , StatusCode , Uri ,
27
+ } ,
26
28
middleware,
27
29
response:: IntoResponse ,
28
30
routing:: { get, get_service, post, MethodRouter } ,
@@ -62,8 +64,8 @@ pub(crate) async fn serve(config: Config) {
62
64
let rewrite_help_as_index = middleware:: from_fn ( rewrite_help_as_index) ;
63
65
64
66
let mut app = Router :: new ( )
65
- . fallback ( root_files)
66
- . nest ( "/assets" , asset_files)
67
+ . fallback_service ( root_files)
68
+ . nest_service ( "/assets" , asset_files)
67
69
. layer ( rewrite_help_as_index)
68
70
. route ( "/evaluate.json" , post ( evaluate) )
69
71
. route ( "/compile" , post ( compile) )
@@ -80,6 +82,7 @@ pub(crate) async fn serve(config: Config) {
80
82
. route ( "/meta/version/clippy" , get_or_post ( meta_version_clippy) )
81
83
. route ( "/meta/version/miri" , get_or_post ( meta_version_miri) )
82
84
. route ( "/meta/gist" , post ( meta_gist_create) )
85
+ . route ( "/meta/gist/" , post ( meta_gist_create) ) // compatibility with lax frontend code
83
86
. route ( "/meta/gist/:id" , get ( meta_gist_get) )
84
87
. route ( "/metrics" , get ( metrics) )
85
88
. route ( "/websocket" , get ( websocket) )
@@ -111,7 +114,7 @@ pub(crate) async fn serve(config: Config) {
111
114
. unwrap ( ) ;
112
115
}
113
116
114
- fn get_or_post < T : ' static > ( handler : impl Handler < T > + Copy ) -> MethodRouter {
117
+ fn get_or_post < T : ' static > ( handler : impl Handler < T , ( ) > + Copy ) -> MethodRouter {
115
118
get ( handler) . post ( handler)
116
119
}
117
120
@@ -419,16 +422,16 @@ impl MetricsAuthorization {
419
422
}
420
423
421
424
#[ async_trait]
422
- impl < B > extract:: FromRequest < B > for MetricsAuthorization
425
+ impl < S > extract:: FromRequestParts < S > for MetricsAuthorization
423
426
where
424
- B : Send ,
427
+ S : Send + Sync ,
425
428
{
426
429
type Rejection = MetricsAuthorizationRejection ;
427
430
428
- async fn from_request ( req : & mut extract :: RequestParts < B > ) -> Result < Self , Self :: Rejection > {
429
- match Extension :: < MetricsToken > :: from_request ( req) . await {
431
+ async fn from_request_parts ( req : & mut Parts , state : & S ) -> Result < Self , Self :: Rejection > {
432
+ match Extension :: < MetricsToken > :: from_request_parts ( req, state ) . await {
430
433
Ok ( Extension ( expected) ) => {
431
- match TypedHeader :: < Authorization < Bearer > > :: from_request ( req) . await {
434
+ match TypedHeader :: < Authorization < Bearer > > :: from_request_parts ( req, state ) . await {
432
435
Ok ( TypedHeader ( Authorization ( actual) ) ) => {
433
436
if actual. token ( ) == * expected. 0 {
434
437
Ok ( Self )
@@ -635,17 +638,18 @@ impl IntoResponse for Error {
635
638
struct Json < T > ( T ) ;
636
639
637
640
#[ async_trait]
638
- impl < T , B > extract:: FromRequest < B > for Json < T >
641
+ impl < T , S , B > extract:: FromRequest < S , B > for Json < T >
639
642
where
640
643
T : serde:: de:: DeserializeOwned ,
641
- B : axum:: body:: HttpBody + Send ,
644
+ S : Send + Sync ,
645
+ B : axum:: body:: HttpBody + Send + ' static ,
642
646
B :: Data : Send ,
643
647
B :: Error : Into < axum:: BoxError > ,
644
648
{
645
649
type Rejection = axum:: response:: Response ;
646
650
647
- async fn from_request ( req : & mut extract :: RequestParts < B > ) -> Result < Self , Self :: Rejection > {
648
- match axum:: Json :: < T > :: from_request ( req) . await {
651
+ async fn from_request ( req : Request < B > , state : & S ) -> Result < Self , Self :: Rejection > {
652
+ match axum:: Json :: < T > :: from_request ( req, state ) . await {
649
653
Ok ( v) => Ok ( Self ( v. 0 ) ) ,
650
654
Err ( e) => {
651
655
let error = format ! ( "Unable to deserialize request: {e}" ) ;
0 commit comments