[docs] Add example usage for Route.HeadersRegexp (#320)

* Add example usage for Route.HeadersRegexp

* Improve example_route_test.go style
This commit is contained in:
Matthew
2017-12-04 08:11:14 -08:00
committed by Kamil Kisiel
parent c572efe429
commit 7904d2e42e
2 changed files with 53 additions and 1 deletions

View File

@@ -258,7 +258,8 @@ func (m headerRegexMatcher) Match(r *http.Request, match *RouteMatch) bool {
// "X-Requested-With", "XMLHttpRequest")
//
// The above route will only match if both the request header matches both regular expressions.
// It the value is an empty string, it will match any value if the key is set.
// If the value is an empty string, it will match any value if the key is set.
// Use the start and end of string anchors (^ and $) to match an exact value.
func (r *Route) HeadersRegexp(pairs ...string) *Route {
if r.err == nil {
var headers map[string]*regexp.Regexp