Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
moraes committed Dec 27, 2012
1 parent 99a7fbf commit b20a198
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b20a198

Please sign in to comment.