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

Method CELLibrary

modules/caddyhttp/matchers.go:1008–1021  ·  view source on GitHub ↗

CELLibrary produces options that expose this matcher for use in CEL expression matchers. Example: expression header({'content-type': 'image/png'}) expression header({'foo': ['bar', 'baz']}) // match bar or baz

(_ caddy.Context)

Source from the content-addressed store, hash-verified

1006// expression header({'content-type': 'image/png'})
1007// expression header({'foo': ['bar', 'baz']}) // match bar or baz
1008func (MatchHeader) CELLibrary(_ caddy.Context) (cel.Library, error) {
1009 return CELMatcherImpl(
1010 "header",
1011 "header_matcher_request_map",
1012 []*cel.Type{CELTypeJSON},
1013 func(data ref.Val) (RequestMatcherWithError, error) {
1014 mapStrListStr, err := CELValueToMapStrList(data)
1015 if err != nil {
1016 return nil, err
1017 }
1018 return MatchHeader(http.Header(mapStrListStr)), nil
1019 },
1020 )
1021}
1022
1023// getHeaderFieldVals returns the field values for the given fieldName from input.
1024// The host parameter should be obtained from the http.Request.Host field, and the

Callers

nothing calls this directly

Calls 4

CELMatcherImplFunction · 0.85
CELValueToMapStrListFunction · 0.85
MatchHeaderTypeAlias · 0.85
HeaderMethod · 0.45

Tested by

no test coverage detected