@@ -2,23 +2,23 @@ use super::*;
22
33impl ServerHook for HttpRequestMiddleware {
44 #[ instrument_trace]
5- async fn new ( _ctx : & Context ) -> Self {
5+ async fn new ( _ctx : & mut Context ) -> Self {
66 Self
77 }
88
99 #[ prologue_macros(
10- reject( ctx. get_request_is_http_version ( ) . await ) ,
10+ reject( ctx. get_request ( ) . get_version ( ) . is_http ( ) ) ,
1111 send,
1212 ) ]
1313 #[ instrument_trace]
14- async fn handle ( self , ctx : & Context ) {
15- ctx. closed ( ) . await ;
14+ async fn handle ( self , ctx : & mut Context ) {
15+ ctx. set_closed ( true ) ;
1616 }
1717}
1818
1919impl ServerHook for CrossMiddleware {
2020 #[ instrument_trace]
21- async fn new ( _ctx : & Context ) -> Self {
21+ async fn new ( _ctx : & mut Context ) -> Self {
2222 Self
2323 }
2424
@@ -27,12 +27,12 @@ impl ServerHook for CrossMiddleware {
2727 #[ response_header( ACCESS_CONTROL_ALLOW_METHODS => ALL_METHODS ) ]
2828 #[ response_header( ACCESS_CONTROL_ALLOW_HEADERS => WILDCARD_ANY ) ]
2929 #[ instrument_trace]
30- async fn handle ( self , ctx : & Context ) { }
30+ async fn handle ( self , ctx : & mut Context ) { }
3131}
3232
3333impl ServerHook for ResponseHeaderMiddleware {
3434 #[ instrument_trace]
35- async fn new ( _ctx : & Context ) -> Self {
35+ async fn new ( _ctx : & mut Context ) -> Self {
3636 Self
3737 }
3838
@@ -45,53 +45,53 @@ impl ServerHook for ResponseHeaderMiddleware {
4545 response_header( "SocketAddr" => socket_addr_string)
4646 ) ]
4747 #[ instrument_trace]
48- async fn handle ( self , ctx : & Context ) {
48+ async fn handle ( self , ctx : & mut Context ) {
4949 let socket_addr_string: String = ctx. get_socket_addr_string ( ) . await ;
5050 let content_type: String = ContentType :: format_content_type_with_charset ( TEXT_HTML , UTF8 ) ;
5151 }
5252}
5353
5454impl ServerHook for ResponseStatusCodeMiddleware {
5555 #[ instrument_trace]
56- async fn new ( _ctx : & Context ) -> Self {
56+ async fn new ( _ctx : & mut Context ) -> Self {
5757 Self
5858 }
5959
6060 #[ response_status_code( 200 ) ]
6161 #[ instrument_trace]
62- async fn handle ( self , ctx : & Context ) { }
62+ async fn handle ( self , ctx : & mut Context ) { }
6363}
6464
6565impl ServerHook for ResponseBodyMiddleware {
6666 #[ instrument_trace]
67- async fn new ( _ctx : & Context ) -> Self {
67+ async fn new ( _ctx : & mut Context ) -> Self {
6868 Self
6969 }
7070
7171 #[ epilogue_macros( response_body( TEMPLATES_INDEX_HTML . replace( "{{ time }}" , & time( ) ) ) ) ]
7272 #[ instrument_trace]
73- async fn handle ( self , ctx : & Context ) { }
73+ async fn handle ( self , ctx : & mut Context ) { }
7474}
7575
7676impl ServerHook for OptionMethodMiddleware {
7777 #[ instrument_trace]
78- async fn new ( _ctx : & Context ) -> Self {
78+ async fn new ( _ctx : & mut Context ) -> Self {
7979 Self
8080 }
8181
8282 #[ prologue_macros(
83- filter( ctx. get_request_is_options_method ( ) . await ) ,
83+ filter( ctx. get_request ( ) . get_method ( ) . is_options ( ) ) ,
8484 send
8585 ) ]
8686 #[ instrument_trace]
87- async fn handle ( self , ctx : & Context ) {
88- ctx. aborted ( ) . await ;
87+ async fn handle ( self , ctx : & mut Context ) {
88+ ctx. set_aborted ( true ) ;
8989 }
9090}
9191
9292impl ServerHook for UpgradeMiddleware {
9393 #[ instrument_trace]
94- async fn new ( _ctx : & Context ) -> Self {
94+ async fn new ( _ctx : & mut Context ) -> Self {
9595 Self
9696 }
9797
@@ -102,9 +102,9 @@ impl ServerHook for UpgradeMiddleware {
102102 response_body( & vec![ ] ) ,
103103 response_header( UPGRADE => WEBSOCKET ) ,
104104 response_header( CONNECTION => UPGRADE ) ,
105- response_header( SEC_WEBSOCKET_ACCEPT => WebSocketFrame :: generate_accept_key( ctx. try_get_request_header_back ( SEC_WEBSOCKET_KEY ) . await . unwrap ( ) ) ) ,
105+ response_header( SEC_WEBSOCKET_ACCEPT => WebSocketFrame :: generate_accept_key( ctx. get_request ( ) . get_header_back ( SEC_WEBSOCKET_KEY ) ) ) ,
106106 send
107107 ) ]
108108 #[ instrument_trace]
109- async fn handle ( self , ctx : & Context ) { }
109+ async fn handle ( self , ctx : & mut Context ) { }
110110}
0 commit comments