Closed
Description
What version of Go are you running? (Paste the output of go version
)
go version go1.12.5 darwin/amd64
What version of gorilla/mux are you at? (Paste the output of git rev-parse HEAD
inside $GOPATH/src/github.com/gorilla/mux
)
github.com/gorilla/mux v1.7.2
Describe your problem (and what you have tried so far)
rtr = mux.NewRouter().StrictSlash(true)
rtr.HandleFunc("/health/", health)
opening /health
will always result in 404 instead of 301
Paste a minimal, runnable, reproduction of your issue below (use backticks to format it)
package main
import (
"github.com/gorilla/mux"
"net/http"
"encoding/json"
)
func main() {
rtr := mux.NewRouter().StrictSlash(true)
rtr.HandleFunc("/health/", health)
s := &http.Server{
Addr: ":8080",
Handler: rtr,
}
s.ListenAndServe()
}
func health(w http.ResponseWriter, r *http.Request) {
status := struct {
Status string
}{
"OK",
}
w.Header().Set("Content-Type", "application/json")
j, _ := json.Marshal(status)
w.Write(j)
}
Metadata
Metadata
Assignees
Labels
No labels