@@ -111,15 +111,20 @@ where
111
111
B :: Error : Display ,
112
112
{
113
113
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 ,
118
123
_ => {
119
124
// Handle other methods or return an error
120
125
let response = Response :: builder ( )
121
126
. status ( http:: StatusCode :: METHOD_NOT_ALLOWED )
122
- . header ( ALLOW , "GET, POST, DELETE" )
127
+ . header ( ALLOW , allowed_methods )
123
128
. body ( Full :: new ( Bytes :: from ( "Method Not Allowed" ) ) . boxed ( ) )
124
129
. expect ( "valid response" ) ;
125
130
return response;
0 commit comments