-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
What version of Go are you running? (Paste the output of go version
)
go version go1.9.3 linux/amd64
What version of gorilla/mux are you at? (Paste the output of git rev-parse HEAD
inside $GOPATH/src/github.com/gorilla/mux
)
c0091a0
Describe your problem (and what you have tried so far)
When using mux.Route.Methods() to set allowed methods, there is no easy way to add CORS. I had a middleware for this, but you run into problems when you have two of "the same" URLs, for example /reports/{eventKey}/{matchKey}
(PUT) and /reports/{eventKey}/{team}
(GET). It would be nice if there was a simple way to integrate CORS with .Methods(), or if there is one already if it were more clear in the documentation.
r.Handle("/reports/{eventKey}/{matchKey}", submitReport).Methods("PUT")
r.Handle("/reports/{eventKey}/{team}", getReportsByEventAndTeam).Methods("GET")
An OPTIONS request or request to either endpoint should have Access-Control-Allow-Methods: "GET", "PUT", "OPTIONS".
Paste a minimal, runnable, reproduction of your issue below (use backticks to format it)
N/A