@@ -48,6 +48,8 @@ pub enum APIRoutingError {
4848 Forbidden ( String ) ,
4949 // 404
5050 NotFound ( String ) ,
51+ // 405
52+ MethodNotAllowed ( String ) ,
5153 // 422
5254 UnprocessableEntity ( String ) ,
5355 // 500
@@ -67,6 +69,7 @@ impl APIRoutingError {
6769 APIRoutingError :: Unauthorized ( _) => StatusCode :: UNAUTHORIZED ,
6870 APIRoutingError :: Forbidden ( _) => StatusCode :: FORBIDDEN ,
6971 APIRoutingError :: NotFound ( _) => StatusCode :: NOT_FOUND ,
72+ APIRoutingError :: MethodNotAllowed ( _) => StatusCode :: METHOD_NOT_ALLOWED ,
7073 APIRoutingError :: UnprocessableEntity ( _) => StatusCode :: UNPROCESSABLE_ENTITY ,
7174 APIRoutingError :: InternalServerError ( _) => StatusCode :: INTERNAL_SERVER_ERROR ,
7275 APIRoutingError :: BadGateway ( _) => StatusCode :: BAD_GATEWAY ,
@@ -90,6 +93,7 @@ impl APIRoutingError {
9093 StatusCode :: UNAUTHORIZED => APIRoutingError :: Unauthorized ( message_string) ,
9194 StatusCode :: FORBIDDEN => APIRoutingError :: Forbidden ( message_string) ,
9295 StatusCode :: NOT_FOUND => APIRoutingError :: NotFound ( message_string) ,
96+ StatusCode :: METHOD_NOT_ALLOWED => APIRoutingError :: MethodNotAllowed ( message_string) ,
9397 StatusCode :: UNPROCESSABLE_ENTITY => {
9498 APIRoutingError :: UnprocessableEntity ( message_string)
9599 }
@@ -148,6 +152,11 @@ impl std::fmt::Display for APIRoutingError {
148152 "{}" ,
149153 parse_api_routing_error_message( message, "Not found" , "" )
150154 ) ,
155+ APIRoutingError :: MethodNotAllowed ( message) => write ! (
156+ f,
157+ "{}" ,
158+ parse_api_routing_error_message( message, "Method not allowed" , "" )
159+ ) ,
151160 APIRoutingError :: UnprocessableEntity ( message) => write ! (
152161 f,
153162 "{}" ,
@@ -184,6 +193,7 @@ impl From<reqwest::Error> for APIRoutingError {
184193 StatusCode :: UNAUTHORIZED => APIRoutingError :: Unauthorized ( e. to_string ( ) ) ,
185194 StatusCode :: FORBIDDEN => APIRoutingError :: Forbidden ( e. to_string ( ) ) ,
186195 StatusCode :: NOT_FOUND => APIRoutingError :: NotFound ( e. to_string ( ) ) ,
196+ StatusCode :: METHOD_NOT_ALLOWED => APIRoutingError :: MethodNotAllowed ( e. to_string ( ) ) ,
187197 StatusCode :: UNPROCESSABLE_ENTITY => {
188198 APIRoutingError :: UnprocessableEntity ( e. to_string ( ) )
189199 }
0 commit comments