Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

buffalo allows mux to handle 405 responses #978

Closed
jeremychase opened this issue Mar 18, 2018 · 2 comments
Closed

buffalo allows mux to handle 405 responses #978

jeremychase opened this issue Mar 18, 2018 · 2 comments
Milestone

Comments

@jeremychase
Copy link

If a 405 handler is defined, it is not used. This can be reproduced by creating an application with a 405 handler:

app.ErrorHandlers[405] = func(status int, err error, c buffalo.Context) error {
  res := c.Response()
  res.WriteHeader(status)
  res.Write([]byte(fmt.Sprintf("Oops!! There was an error %s", err.Error())))
  return nil
}
app.GET("/", HomeHandler)

The defined handler does not get used:

$ curl localhost:3000/ -i -X POST
HTTP/1.1 405 Method Not Allowed
Date: Sun, 18 Mar 2018 20:28:56 GMT
Content-Length: 0

Backstory: https://gophers.slack.com/archives/C3MSAFD40/p1521402776000101

@markbates
Copy link
Member

@jeremychase in case you're curious, here's the PR to fix this #979

@jeremychase
Copy link
Author

@markbates Ah - thank you - that clarifies what was happening:

https://github.com/gorilla/mux/blob/master/mux.go#L43-L68

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

No branches or pull requests

2 participants