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

HTTP 405 Method Not Allowed #54

Closed
pnelson opened this issue Aug 5, 2014 · 2 comments
Closed

HTTP 405 Method Not Allowed #54

pnelson opened this issue Aug 5, 2014 · 2 comments

Comments

@pnelson
Copy link

pnelson commented Aug 5, 2014

When a path matches but the method doesn't, I'd like to respond with a custom MethodNotAllowed handler. Is this something you'd consider?

@zenazn
Copy link
Owner

zenazn commented Aug 5, 2014

Is there a reason you can't use a middleware to catch 405s?

It means there's an unfortunate amount of legwork you need to do (it requires having a custom http.ResponseWriter), but such a middleware would be more widely applicable than a Goji router-specific hack—if another middleware layer returned an HTTP 405 of its own, for instance, you could set things up such that your middleware would also catch it.

@pnelson
Copy link
Author

pnelson commented Aug 5, 2014

I think c.Env[web.ValidMethodsKey] is what I was looking for. I just didn't realize this was available until now. I'll try it out when I get some time but I suspect it should be similar to the automatic options middleware. Thanks.

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

No branches or pull requests

2 participants