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

404 not found when expecting 405 method not allowed #44

Closed
mrcpvn opened this issue Jun 1, 2016 · 4 comments
Closed

404 not found when expecting 405 method not allowed #44

mrcpvn opened this issue Jun 1, 2016 · 4 comments

Comments

@mrcpvn
Copy link

mrcpvn commented Jun 1, 2016

A request sent to an existing resource without an handler for that method should return http 405.
If I understand correctly this should be the behaviour in

// Check if method is supported by chi
method, ok := methodMap[r.Method]
if !ok {
    methodNotAllowedHandler(ctx, w, r)
    return
}

but I am getting always an http 404 error.
methodMap is initialized at startup and a method will be always found in the map, after that an handler will not be found and we finish in the handler not found case.

Maybe this control has been implemented to manage unexpected http methods that the router will not be able to handle in every case. Am I right?

@pkieltyka
Copy link
Member

@mrcpvn yea, with 404, it lets you mount the NotFound() handler and response to the user. I'm open to just returning a 405, but then theres no control to the app developer here. I'll think about this some more for chi v2

@mrcpvn mrcpvn closed this as completed Jun 8, 2016
@pkieltyka
Copy link
Member

@mrcpvn how come you've closed it...? have you solved this in a different way?

@mrcpvn
Copy link
Author

mrcpvn commented Jun 8, 2016

I closed the issue because the same feature can be created with a middleware.
From my point of view this is not a bug if the methodNotAllowedHandler is used to handle an http method that is not expected from the chi.Router.

@pkieltyka
Copy link
Member

makes sense, thanks for the followup!

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