func (m MatchExpression) Match(r *http.Request) bool {
	out, _, _ := m.prg.Eval(map[string]interface{}{
		"request": celHTTPRequest{r},
	})
	if outBool, ok := out.Value().(bool); ok {
		return outBool
	}
	return false
}
Match returns true if r matches m.
package caddyhttp
import (
	"crypto/x509/pkix"
	"encoding/json"
	"fmt"
	"net/http"
	"reflect"
	"regexp"
	"strings"
	"time"
	"github.com/caddyserver/caddy/v2"
	"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
	"github.com/google/cel-go/cel"
	"github.com/google/cel-go/checker/decls"
	"github.com/google/cel-go/common/types"
	"github.com/google/cel-go/common/types/ref"
	"github.com/google/cel-go/common/types/traits"
	"github.com/google/cel-go/ext"
	"github.com/google/cel-go/interpreter/functions"
	exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
	"google.golang.org/protobuf/proto"
)
func init() {
	caddy.RegisterModule(MatchExpression{})
}
type MatchExpression struct {
	Expr string
	expandedExpr string
	prg          cel.Program
	ta           ref.TypeAdapter
}
func (MatchExpression) CaddyModule() caddy.ModuleInfo {
	return caddy.ModuleInfo{
		ID:  "http.matchers.expression",
		New: func() caddy.Module { return new(MatchExpression) },
	}
}
func (m MatchExpression) MarshalJSON() ([]byte, error) {
	return json.Marshal(m.Expr)
}
func (m *MatchExpression) UnmarshalJSON(data []byte) error {
	return json.Unmarshal(data, &m.Expr)
}
func (m *MatchExpression) Provision(_ caddy.Context) error {
	m.expandedExpr = placeholderRegexp.ReplaceAllString(m.Expr, placeholderExpansion)
	m.ta = celTypeAdapter{}
	env, err := cel.NewEnv(
		cel.Declarations(
			decls.NewVar("request", httpRequestObjectType),
			decls.NewFunction(placeholderFuncName,
				decls.NewOverload(placeholderFuncName+"_httpRequest_string",
					[]*exprpb.Type{httpRequestObjectType, decls.String},
					decls.Any)),
		),
		cel.CustomTypeAdapter(m.ta),
		ext.Strings(),
	)
	if err != nil {
		return fmt.Errorf("setting up CEL environment: %v", err)
	}
	checked, issues := env.Compile(m.expandedExpr)
	if issues != nil && issues.Err() != nil {
		return fmt.Errorf("compiling CEL program: %s", issues.Err())
	}
	if !proto.Equal(checked.ResultType(), decls.Bool) {
		return fmt.Errorf("CEL request matcher expects return type of bool, not %s", checked.ResultType())
	}
	m.prg, err = env.Program(checked,
		cel.Functions(
			&functions.Overload{
				Operator: placeholderFuncName,
				Binary:   m.caddyPlaceholderFunc,
			},
		),
	)
	if err != nil {
		return fmt.Errorf("compiling CEL program: %s", err)
	}
	return nil
}