Seems similar to #18 but still happens with current version:
package main
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
"github.com/sanity-io/litter"
)
func main() {
r := mux.NewRouter()
r.HandleFunc(`/foo`, AnyHandler).Name("named")
r.HandleFunc("/", AnyHandler).Name("front")
srv := &http.Server{
Handler: r,
Addr: "127.0.0.1:8000",
}
log.Fatal(srv.ListenAndServe())
}
func AnyHandler(w http.ResponseWriter, r *http.Request) {
route := mux.CurrentRoute(r)
litter.Config.HidePrivateFields = false
fmt.Fprintln(w, route.GetName())
defer func() {
p := recover()
if p != nil {
fmt.Printf("Recovered: %#v\n", p)
}
}()
litter.Sdump(route)
}
- Navigate to either
/ or /foo
- Panics with:
"reflect.Value.Interface: cannot return value obtained from unexported field or method"
- Does not panic if only one of the routes is handled
- Does not panic if either of the routes is not named
Seems similar to #18 but still happens with current version:
/or/foo"reflect.Value.Interface: cannot return value obtained from unexported field or method"