ExtractMatcherSet is like MatcherToken, except this is a higher-level method that returns the matcher set described by the matcher token, or nil if there is none, and deletes the matcher token from the dispenser and resets it as if this look-ahead never happened. Useful when wrapping a route (one or
()
| 260 | // dispenser and resets it as if this look-ahead never happened. Useful |
| 261 | // when wrapping a route (one or more handlers) in a user-defined matcher. |
| 262 | func (h Helper) ExtractMatcherSet() (caddy.ModuleMap, error) { |
| 263 | matcherSet, hasMatcher, err := h.MatcherToken() |
| 264 | if err != nil { |
| 265 | return nil, err |
| 266 | } |
| 267 | if hasMatcher { |
| 268 | // strip matcher token; we don't need to |
| 269 | // use the return value here because a |
| 270 | // new dispenser should have been made |
| 271 | // solely for this directive's tokens, |
| 272 | // with no other uses of same slice |
| 273 | h.Dispenser.Delete() |
| 274 | } |
| 275 | h.Dispenser.Reset() // pretend this lookahead never happened |
| 276 | return matcherSet, nil |
| 277 | } |
| 278 | |
| 279 | // NewRoute returns config values relevant to creating a new HTTP route. |
| 280 | func (h Helper) NewRoute(matcherSet caddy.ModuleMap, |
no test coverage detected