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

Method MatchWithError

modules/caddyhttp/matchers.go:1141–1158  ·  modules/caddyhttp/matchers.go::MatchHeaderRE.MatchWithError

MatchWithError returns true if r matches m.

(r *http.Request)

Source from the content-addressed store, hash-verified

1139
1140// MatchWithError returns true if r matches m.
1141func (m MatchHeaderRE) MatchWithError(r *http.Request) (bool, error) {
1142 for field, rm := range m {
1143 actualFieldVals := getHeaderFieldVals(r.Header, field, r.Host, r.TransferEncoding)
1144 match := false
1145 fieldVal:
1146 for _, actualFieldVal := range actualFieldVals {
1147 repl := r.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer)
1148 if rm.Match(actualFieldVal, repl) {
1149 match = true
1150 break fieldVal
1151 }
1152 }
1153 if !match {
1154 return false, nil
1155 }
1156 }
1157 return true, nil
1158}
1159
1160// Provision compiles m's regular expressions.
1161func (m MatchHeaderRE) Provision(ctx caddy.Context) error {

Callers 2

BenchmarkHeaderREMatcherFunction · 0.95
MatchMethod · 0.95

Calls 3

getHeaderFieldValsFunction · 0.85
MatchMethod · 0.65
ValueMethod · 0.45

Tested by 1

BenchmarkHeaderREMatcherFunction · 0.76