Skip to content

Commit e592981

Browse files
Fixes #12
return http.StatusMethodNotAllowed when appropriate
1 parent 9f0f858 commit e592981

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

oapi_validate.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ func ValidateRequestFromContext(ctx echo.Context, router routers.Router, options
118118
if err != nil {
119119
switch e := err.(type) {
120120
case *routers.RouteError:
121+
// The path may exist on the server, but the method is not allowed.
122+
if errors.Is(e, routers.ErrMethodNotAllowed) {
123+
return echo.NewHTTPError(http.StatusMethodNotAllowed, e.Reason)
124+
}
121125
// We've got a bad request, the path requested doesn't match
122126
// either server, or path, or something.
123127
return echo.NewHTTPError(http.StatusNotFound, e.Reason)

0 commit comments

Comments
 (0)