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

405 Method Not Allowed #30

Closed
claudiofelber opened this issue Sep 1, 2014 · 2 comments
Closed

405 Method Not Allowed #30

claudiofelber opened this issue Sep 1, 2014 · 2 comments
Labels

Comments

@claudiofelber
Copy link

Hi Julien

The router currently returns 404 Not Found even if the path (and thus the resource) exists but the request method does not match. In such a situation, to be a good HTTP citizen, it should return 405 Method Not Allowed and indicate the available methods for the desired resource in the "Allow" header.

I've looked into your router implementation. The way the routes are currently organized, doing this wouldn't be that easy (and fast) because you have a separate tree for each request method. I think you should have one tree instead and store the defined methods along with their handlers in the node structure.

To customize the server response, in addition to the NotFound handler to be found in the Router structure, there should also be a MethodNotAllowed handler. It should be passed a list of allowed methods.

Regards,
Claudio

@ydnar
Copy link

ydnar commented Jan 6, 2015

The current implementation returns 405 for all requests if there’s a more general (e.g. wildcard) route for another method, e.g.:

r.Handle("GET", "/v1/search", search)
r.Handle("OPTIONS", "/*path", handler)

GET requests for /v1/search will always return a 405 with this change.

@julienschmidt
Copy link
Owner

#51 was now reverted (#52).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants