Skip to content

Commit

Permalink
return http.StatusMethodNotAllowed when appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
florentchauveau committed Jan 5, 2025
1 parent 9f0f858 commit 91d2506
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions oapi_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ func ValidateRequestFromContext(ctx echo.Context, router routers.Router, options
if err != nil {
switch e := err.(type) {
case *routers.RouteError:
// The path may exist on the server, but the method is not allowed.
if errors.Is(e, routers.ErrMethodNotAllowed) {
return echo.NewHTTPError(http.StatusMethodNotAllowed, e.Reason)
}
// We've got a bad request, the path requested doesn't match
// either server, or path, or something.
return echo.NewHTTPError(http.StatusNotFound, e.Reason)
Expand Down

0 comments on commit 91d2506

Please sign in to comment.