moraes 13 years ago
parent
commit
b20a198901
  1. 22
      mux_test.go

22
mux_test.go

@ -656,6 +656,28 @@ func testRoute(t *testing.T, test routeTest) { @@ -656,6 +656,28 @@ func testRoute(t *testing.T, test routeTest) {
}
}
// https://plus.google.com/101022900381697718949/posts/eWy6DjFJ6uW
func testSubrouterHeader(t *testing.T, test routeTest) {
func1 := func(http.ResponseWriter, *http.Request) {}
func2 := func(http.ResponseWriter, *http.Request) {}
r := NewRouter()
s := r.Headers("SomeSpecialHeader").Subrouter()
s.HandleFunc("/", func1).Name("func1")
r.HandleFunc("/", func2).Name("func2")
req, _ := http.NewRequest("GET", "http://localhost/", nil)
req.Header.Add("SomeSpecialHeader", "")
match := new(RouteMatch)
matched := r.Match(req, match)
if !matched {
t.Errorf("Should match request")
}
if match.Route.GetName() != "func1" {
t.Errorf("Expecting func1 handler")
}
}
// mapToPairs converts a string map to a slice of string pairs
func mapToPairs(m map[string]string) []string {
var i int

Loading…
Cancel
Save