Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 13, 16:45 UTC
Finish fixing lint errors from ea8df6ff
Follows up #4915
Matthew Holt committed
Jul 28, 2022 at 15:16 UTC
4fced0b6e15429dd51e6edc2c244f7af068ecf84
2 files changed
+8
-12
modules/caddyhttp/celmatcher.go
-1
@@ -345,7 +345,6 @@ func CELMatcherImpl(macroName, funcName string, matcherDataTypes []*cel.Type, fa
345
cel.Macros(macro),
346
cel.Function(funcName,
347
cel.Overload(funcName, append([]*cel.Type{requestType}, matcherDataTypes...), cel.BoolType),
348
-
348
cel.SingletonBinaryImpl(CELMatcherRuntimeFunction(funcName, fac))),
349
}
350
programOptions := []cel.ProgramOption{
modules/caddyhttp/fileserver/matcher.go
+8
-11
@@ -30,7 +30,6 @@ import (
30
"github.com/google/cel-go/common"
31
"github.com/google/cel-go/common/operators"
32
"github.com/google/cel-go/common/types/ref"
33
- "github.com/google/cel-go/interpreter/functions"
33
"github.com/google/cel-go/parser"
34
exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
35
)
@@ -153,10 +152,6 @@ func (m *MatchFile) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
152
// expression file({'root': '/srv', 'try_files': [{http.request.uri.path}, '/index.php'], 'try_policy': 'first_exist', 'split_path': ['.php']})
153
func (MatchFile) CELLibrary(ctx caddy.Context) (cel.Library, error) {
154
requestType := cel.ObjectType("http.Request")
156
- envOptions := []cel.EnvOption{
157
- cel.Macros(parser.NewGlobalVarArgMacro("file", celFileMatcherMacroExpander())),
158
- cel.Function("file", cel.Overload("file_request_map", []*cel.Type{requestType, caddyhttp.CELTypeJSON}, cel.BoolType)),
159
- }
155
156
matcherFactory := func(data ref.Val) (caddyhttp.RequestMatcher, error) {
157
values, err := caddyhttp.CELValueToMapStrList(data)
@@ -185,14 +180,16 @@ func (MatchFile) CELLibrary(ctx caddy.Context) (cel.Library, error) {
180
return m, err
181
}
182
183
+ envOptions := []cel.EnvOption{
184
+ cel.Macros(parser.NewGlobalVarArgMacro("file", celFileMatcherMacroExpander())),
185
+ cel.Function("file", cel.Overload("file_request_map", []*cel.Type{requestType, caddyhttp.CELTypeJSON}, cel.BoolType)),
186
+ cel.Function("file_request_map",
187
+ cel.Overload("file_request_map", []*cel.Type{requestType, caddyhttp.CELTypeJSON}, cel.BoolType),
188
+ cel.SingletonBinaryImpl(caddyhttp.CELMatcherRuntimeFunction("file_request_map", matcherFactory))),
189
+ }
190
+
191
programOptions := []cel.ProgramOption{
192
cel.CustomDecorator(caddyhttp.CELMatcherDecorator("file_request_map", matcherFactory)),
190
- cel.Functions(
191
- &functions.Overload{
192
- Operator: "file_request_map",
193
- Binary: caddyhttp.CELMatcherRuntimeFunction("file_request_map", matcherFactory),
194
- },
195
- ),
193
}
194
195
return caddyhttp.NewMatcherCELLibrary(envOptions, programOptions), nil