aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/fileserver/matcher.go
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2022-07-28 15:16:36 -0600
committerMatthew Holt <[email protected]>2022-07-28 15:16:36 -0600
commit4fced0b6e15429dd51e6edc2c244f7af068ecf84 (patch)
tree7e4af23e273ecd46d5db165b845ac979eb3d3ddc /modules/caddyhttp/fileserver/matcher.go
parent1bdd451913c065ce555d4e2bdb891946b61ffd87 (diff)
downloadcaddy-4fced0b6e15429dd51e6edc2c244f7af068ecf84.tar.gz
caddy-4fced0b6e15429dd51e6edc2c244f7af068ecf84.zip
Finish fixing lint errors from ea8df6ff
Follows up #4915
Diffstat (limited to 'modules/caddyhttp/fileserver/matcher.go')
-rw-r--r--modules/caddyhttp/fileserver/matcher.go19
1 files changed, 8 insertions, 11 deletions
diff --git a/modules/caddyhttp/fileserver/matcher.go b/modules/caddyhttp/fileserver/matcher.go
index 7ed934341..3ef3e47a2 100644
--- a/modules/caddyhttp/fileserver/matcher.go
+++ b/modules/caddyhttp/fileserver/matcher.go
@@ -30,7 +30,6 @@ import (
"github.com/google/cel-go/common"
"github.com/google/cel-go/common/operators"
"github.com/google/cel-go/common/types/ref"
- "github.com/google/cel-go/interpreter/functions"
"github.com/google/cel-go/parser"
exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
)
@@ -153,10 +152,6 @@ func (m *MatchFile) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
// expression file({'root': '/srv', 'try_files': [{http.request.uri.path}, '/index.php'], 'try_policy': 'first_exist', 'split_path': ['.php']})
func (MatchFile) CELLibrary(ctx caddy.Context) (cel.Library, error) {
requestType := cel.ObjectType("http.Request")
- envOptions := []cel.EnvOption{
- cel.Macros(parser.NewGlobalVarArgMacro("file", celFileMatcherMacroExpander())),
- cel.Function("file", cel.Overload("file_request_map", []*cel.Type{requestType, caddyhttp.CELTypeJSON}, cel.BoolType)),
- }
matcherFactory := func(data ref.Val) (caddyhttp.RequestMatcher, error) {
values, err := caddyhttp.CELValueToMapStrList(data)
@@ -185,14 +180,16 @@ func (MatchFile) CELLibrary(ctx caddy.Context) (cel.Library, error) {
return m, err
}
+ envOptions := []cel.EnvOption{
+ cel.Macros(parser.NewGlobalVarArgMacro("file", celFileMatcherMacroExpander())),
+ cel.Function("file", cel.Overload("file_request_map", []*cel.Type{requestType, caddyhttp.CELTypeJSON}, cel.BoolType)),
+ cel.Function("file_request_map",
+ cel.Overload("file_request_map", []*cel.Type{requestType, caddyhttp.CELTypeJSON}, cel.BoolType),
+ cel.SingletonBinaryImpl(caddyhttp.CELMatcherRuntimeFunction("file_request_map", matcherFactory))),
+ }
+
programOptions := []cel.ProgramOption{
cel.CustomDecorator(caddyhttp.CELMatcherDecorator("file_request_map", matcherFactory)),
- cel.Functions(
- &functions.Overload{
- Operator: "file_request_map",
- Binary: caddyhttp.CELMatcherRuntimeFunction("file_request_map", matcherFactory),
- },
- ),
}
return caddyhttp.NewMatcherCELLibrary(envOptions, programOptions), nil