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

Function celMatcherStringMacroExpander

modules/caddyhttp/celmatcher.go:613–623  ·  view source on GitHub ↗

celMatcherStringMacroExpander validates that the macro is called a single string argument. The following function call is returned: <funcName>(request, arg)

(funcName string)

Source from the content-addressed store, hash-verified

611//
612// The following function call is returned: <funcName>(request, arg)
613func celMatcherStringMacroExpander(funcName string) parser.MacroExpander {
614 return func(eh cel.MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) {
615 if len(args) != 1 {
616 return nil, eh.NewError(0, "matcher requires one argument")
617 }
618 if isCELStringExpr(args[0]) {
619 return eh.NewCall(funcName, eh.NewIdent(CELRequestVarName), args[0]), nil
620 }
621 return nil, eh.NewError(args[0].ID(), "matcher argument must be a string literal")
622 }
623}
624
625// celMatcherJSONMacroExpander validates that the macro is called a single
626// map literal argument.

Callers 1

CELMatcherImplFunction · 0.85

Calls 2

IDMethod · 0.80
isCELStringExprFunction · 0.70

Tested by

no test coverage detected