Headers adds a matcher for request header values. It accepts a sequence of key/value pairs to be matched. For example: r := mux.NewRouter().NewRoute() r.Headers("Content-Type", "application/json", "X-Requested-With", "XMLHttpRequest") The above route will only match if both request he
(pairs ...string)
| 247 | // The above route will only match if both request header values match. |
| 248 | // If the value is an empty string, it will match any value if the key is set. |
| 249 | func (r *Route) Headers(pairs ...string) *Route { |
| 250 | if r.err == nil { |
| 251 | var headers map[string]string |
| 252 | headers, r.err = mapFromPairsToString(pairs...) |
| 253 | return r.addMatcher(headerMatcher(headers)) |
| 254 | } |
| 255 | return r |
| 256 | } |
| 257 | |
| 258 | // headerRegexMatcher matches the request against the route given a regex for the header |
| 259 | type headerRegexMatcher map[string]*regexp.Regexp |
nothing calls this directly
no test coverage detected