@@ -111,15 +111,20 @@ where
111111 B :: Error : Display ,
112112 {
113113 let method = request. method ( ) . clone ( ) ;
114- let result = match method {
115- Method :: GET => self . handle_get ( request) . await ,
116- Method :: POST => self . handle_post ( request) . await ,
117- Method :: DELETE => self . handle_delete ( request) . await ,
114+ let allowed_methods = match self . config . stateful_mode {
115+ true => "GET, POST, DELETE" ,
116+ false => "POST" ,
117+ } ;
118+ let result = match ( method, self . config . stateful_mode ) {
119+ ( Method :: POST , _) => self . handle_post ( request) . await ,
120+ // if we're not in stateful mode, we don't support GET or DELETE because there is no session
121+ ( Method :: GET , true ) => self . handle_get ( request) . await ,
122+ ( Method :: DELETE , true ) => self . handle_delete ( request) . await ,
118123 _ => {
119124 // Handle other methods or return an error
120125 let response = Response :: builder ( )
121126 . status ( http:: StatusCode :: METHOD_NOT_ALLOWED )
122- . header ( ALLOW , "GET, POST, DELETE" )
127+ . header ( ALLOW , allowed_methods )
123128 . body ( Full :: new ( Bytes :: from ( "Method Not Allowed" ) ) . boxed ( ) )
124129 . expect ( "valid response" ) ;
125130 return response;
0 commit comments