File tree Expand file tree Collapse file tree 3 files changed +14
-6
lines changed
Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ pub trait HttpHandler: Clone + Send + Sync + 'static {
115115 }
116116
117117 /// Whether a CONNECT request should be intercepted. Defaults to `true` for all requests.
118- async fn should_intercept ( & mut self , _req : & Request < Body > ) -> bool {
118+ async fn should_intercept ( & mut self , _ctx : & HttpContext , _req : & Request < Body > ) -> bool {
119119 true
120120 }
121121}
Original file line number Diff line number Diff line change 6969 H : HttpHandler ,
7070 W : WebSocketHandler ,
7171{
72+ fn context ( & self ) -> HttpContext {
73+ HttpContext {
74+ client_addr : self . client_addr ,
75+ }
76+ }
77+
7278 #[ instrument(
7379 skip_all,
7480 fields(
8288 mut self ,
8389 req : Request < Body > ,
8490 ) -> Result < Response < Body > , hyper:: Error > {
85- let ctx = HttpContext {
86- client_addr : self . client_addr ,
87- } ;
91+ let ctx = self . context ( ) ;
8892
8993 let req = match self
9094 . http_handler
@@ -136,7 +140,11 @@ where
136140 bytes:: Bytes :: copy_from_slice ( buffer[ ..bytes_read] . as_ref ( ) ) ,
137141 ) ;
138142
139- if self . http_handler . should_intercept ( & req) . await {
143+ if self
144+ . http_handler
145+ . should_intercept ( & self . context ( ) , & req)
146+ . await
147+ {
140148 if buffer == * b"GET " {
141149 if let Err ( e) =
142150 self . serve_stream ( upgraded, Scheme :: HTTP , authority) . await
Original file line number Diff line number Diff line change @@ -305,7 +305,7 @@ impl HttpHandler for TestHandler {
305305 decode_response ( res) . unwrap ( )
306306 }
307307
308- async fn should_intercept ( & mut self , _req : & Request < Body > ) -> bool {
308+ async fn should_intercept ( & mut self , _ctx : & HttpContext , _req : & Request < Body > ) -> bool {
309309 self . should_intercept
310310 }
311311}
You can’t perform that action at this time.
0 commit comments