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

Method CELLibrary

modules/caddyhttp/vars.go:231–244  ·  view source on GitHub ↗

CELLibrary produces options that expose this matcher for use in CEL expression matchers. Example: expression vars({'{magic_number}': ['3', '5']}) expression vars({'{foo}': 'single_value'})

(_ caddy.Context)

Source from the content-addressed store, hash-verified

229// expression vars({'{magic_number}': ['3', '5']})
230// expression vars({'{foo}': 'single_value'})
231func (VarsMatcher) CELLibrary(_ caddy.Context) (cel.Library, error) {
232 return CELMatcherImpl(
233 "vars",
234 "vars_matcher_request_map",
235 []*cel.Type{CELTypeJSON},
236 func(data ref.Val) (RequestMatcherWithError, error) {
237 mapStrListStr, err := CELValueToMapStrList(data)
238 if err != nil {
239 return nil, err
240 }
241 return VarsMatcher(mapStrListStr), nil
242 },
243 )
244}
245
246// MatchVarsRE matches the value of the context variables by a given regular expression.
247//

Callers

nothing calls this directly

Calls 3

CELMatcherImplFunction · 0.85
CELValueToMapStrListFunction · 0.85
VarsMatcherTypeAlias · 0.85

Tested by

no test coverage detected