Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] The default MethodNotAllowedHandler is not spec compliant #554

Closed
rocketspacer opened this issue Feb 20, 2020 · 4 comments
Closed

[bug] The default MethodNotAllowedHandler is not spec compliant #554

rocketspacer opened this issue Feb 20, 2020 · 4 comments
Assignees
Labels

Comments

@rocketspacer
Copy link

@rocketspacer rocketspacer commented Feb 20, 2020

RFC 7231 Section 6.5.5

States that

The origin server MUST generate an
Allow header field in a 405 response containing a list of the target
resource's currently supported methods.

Which is clearly not implemented right now

mux/mux.go

Lines 601 to 603 in 75dcda0

func methodNotAllowed(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusMethodNotAllowed)
}

Suggestion:

  • Rather than assign a default MethodNotAllowedHandler just reuse the NotFoundHandler so it's both backward compatible and spec-compliant.
@rocketspacer rocketspacer added the bug label Feb 20, 2020
@elithrar
Copy link
Member

@elithrar elithrar commented Feb 20, 2020

Happy to take a PR + tests for this.

@rocketspacer
Copy link
Author

@rocketspacer rocketspacer commented Feb 20, 2020

@elithrar Would you prefer a flag to skip handling MethodNotAllowed or removing the default MethodNotAllowed handler altogether? (meaning: MethodNotAllowed will only be handled if the handler is explicitly specified)

Or even something like ExplicitMethodNotAllowedHandler to flag the 2nd proposal.

@elithrar
Copy link
Member

@elithrar elithrar commented Apr 11, 2020

See comments in #555

@stale
Copy link

@stale stale bot commented Jun 26, 2020

This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.

@stale stale bot added the stale label Jun 26, 2020
@stale stale bot closed this Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.