MCPcopy
hub / github.com/gorilla/mux / HeadersRegexp

Method HeadersRegexp

route.go:275–282  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
275func (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

Callers 3

TestHeadersFunction · 0.80

Calls 3

addMatcherMethod · 0.95
mapFromPairsToRegexFunction · 0.85
headerRegexMatcherTypeAlias · 0.85

Tested by 3

TestHeadersFunction · 0.64