MCPcopy
hub / github.com/caddyserver/caddy / ExtractMatcherSet

Method ExtractMatcherSet

caddyconfig/httpcaddyfile/directives.go:262–277  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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.
262func (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.
280func (h Helper) NewRoute(matcherSet caddy.ModuleMap,

Callers 8

parseACMEServerFunction · 0.80
parseCaddyfileRewriteFunction · 0.80
parseCaddyfileFunction · 0.80
parsePHPFastCGIFunction · 0.80
parseCaddyfileFunction · 0.80
parseReqHdrCaddyfileFunction · 0.80
parseRootFunction · 0.80
RegisterHandlerDirectiveFunction · 0.80

Calls 3

MatcherTokenMethod · 0.95
ResetMethod · 0.65
DeleteMethod · 0.45

Tested by

no test coverage detected