File tree 4 files changed +18
-27
lines changed
4 files changed +18
-27
lines changed Original file line number Diff line number Diff line change @@ -54,11 +54,6 @@ impl<AppData> Context<AppData> {
54
54
& self . request
55
55
}
56
56
57
- /// Mutably access the request body
58
- pub fn body ( & mut self ) -> & mut http_service:: Body {
59
- self . request . body_mut ( )
60
- }
61
-
62
57
/// Access app-global data.
63
58
pub fn app_data ( & self ) -> & AppData {
64
59
& self . app_data
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ impl<AppData> ExtractCookies for Context<AppData> {
24
24
. unwrap_or_else ( || CookieData {
25
25
content : self
26
26
. headers ( )
27
- . get ( "Cookie " )
27
+ . get ( "tide-cookie " )
28
28
. and_then ( |raw| parse_from_header ( raw. to_str ( ) . unwrap ( ) ) . ok ( ) )
29
29
. unwrap_or_default ( ) ,
30
30
} ) ;
Original file line number Diff line number Diff line change 1
1
use futures:: future:: { Future , FutureObj } ;
2
- use std:: pin:: Pin ;
3
2
4
3
use crate :: { response:: IntoResponse , Context , Response } ;
5
4
@@ -49,26 +48,11 @@ where
49
48
Fut : Future + Send + ' static ,
50
49
Fut :: Output : IntoResponse ,
51
50
{
52
- type Fut = ResponseWrapper < Fut > ;
51
+ type Fut = FutureObj < ' static , Response > ;
53
52
fn call ( & self , cx : Context < AppData > ) -> Self :: Fut {
54
- ResponseWrapper { fut : ( self ) ( cx) }
55
- }
56
- }
57
-
58
- /// The future retured by the endpoint implementation for `Fn` types.
59
- pub struct ResponseWrapper < F > {
60
- fut : F ,
61
- }
62
-
63
- impl < F > Future for ResponseWrapper < F >
64
- where
65
- F : Future ,
66
- F :: Output : IntoResponse ,
67
- {
68
- type Output = Response ;
69
-
70
- fn poll ( self : Pin < & mut Self > , waker : & std:: task:: Waker ) -> std:: task:: Poll < Response > {
71
- let inner = unsafe { self . map_unchecked_mut ( |wrapper| & mut wrapper. fut ) } ;
72
- inner. poll ( waker) . map ( IntoResponse :: into_response)
53
+ let fut = ( self ) ( cx) ;
54
+ box_async ! {
55
+ await !( fut) . into_response( )
56
+ }
73
57
}
74
58
}
Original file line number Diff line number Diff line change @@ -74,6 +74,18 @@ pub trait ResultExt<T>: Sized {
74
74
StatusCode : HttpTryFrom < S > ;
75
75
}
76
76
77
+ /// Extends the `Response` type with a method to extract error causes when applicable.
78
+ pub trait ResponseExt {
79
+ /// Extract the cause of the unsuccessful response, if any
80
+ fn err_cause ( & self ) -> Option < & ( dyn std:: error:: Error + Send + Sync + ' static ) > ;
81
+ }
82
+
83
+ impl < T > ResponseExt for Response < T > {
84
+ fn err_cause ( & self ) -> Option < & ( dyn std:: error:: Error + Send + Sync + ' static ) > {
85
+ self . extensions ( ) . get ( ) . map ( |Cause ( c) | & * * c)
86
+ }
87
+ }
88
+
77
89
impl < T , E : std:: error:: Error + Send + Sync + ' static > ResultExt < T > for std:: result:: Result < T , E > {
78
90
fn with_err_status < S > ( self , status : S ) -> EndpointResult < T >
79
91
where
You can’t perform that action at this time.
0 commit comments