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

Method UnmarshalCaddyfile

modules/caddyhttp/vars.go:264–296  ·  view source on GitHub ↗

UnmarshalCaddyfile implements caddyfile.Unmarshaler.

(d *caddyfile.Dispenser)

Source from the content-addressed store, hash-verified

262
263// UnmarshalCaddyfile implements caddyfile.Unmarshaler.
264func (m *MatchVarsRE) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
265 if *m == nil {
266 *m = make(map[string]*MatchRegexp)
267 }
268 // iterate to merge multiple matchers into one
269 for d.Next() {
270 var first, second, third string
271 if !d.Args(&first, &second) {
272 return d.ArgErr()
273 }
274
275 var name, field, val string
276 if d.Args(&third) {
277 name = first
278 field = second
279 val = third
280 } else {
281 field = first
282 val = second
283 }
284
285 // Default to the named matcher's name, if no regexp name is provided
286 if name == "" {
287 name = d.GetContextString(caddyfile.MatcherNameCtxKey)
288 }
289
290 (*m)[field] = &MatchRegexp{Pattern: val, Name: name}
291 if d.NextBlock(0) {
292 return d.Err("malformed vars_regexp matcher: blocks are not supported")
293 }
294 }
295 return nil
296}
297
298// Provision compiles m's regular expressions.
299func (m MatchVarsRE) Provision(ctx caddy.Context) error {

Callers

nothing calls this directly

Calls 6

ArgsMethod · 0.80
ArgErrMethod · 0.80
GetContextStringMethod · 0.80
NextBlockMethod · 0.80
ErrMethod · 0.80
NextMethod · 0.65

Tested by

no test coverage detected