HeadersRegexp accepts a sequence of key/value pairs, where the value has regex support. For example: r := mux.NewRouter().NewRoute() r.HeadersRegexp("Content-Type", "application/(text|json)", "X-Requested-With", "XMLHttpRequest") The above route will only match if both the request hea
(pairs ...string)
| 273 | // If the value is an empty string, it will match any value if the key is set. |
| 274 | // Use the start and end of string anchors (^ and $) to match an exact value. |
| 275 | func (r *Route) HeadersRegexp(pairs ...string) *Route { |
| 276 | if r.err == nil { |
| 277 | var headers map[string]*regexp.Regexp |
| 278 | headers, r.err = mapFromPairsToRegex(pairs...) |
| 279 | return r.addMatcher(headerRegexMatcher(headers)) |
| 280 | } |
| 281 | return r |
| 282 | } |
| 283 | |
| 284 | // Host ----------------------------------------------------------------------- |
| 285 |