MatchWithError returns true if r matches m.
(r *http.Request)
| 1139 | |
| 1140 | // MatchWithError returns true if r matches m. |
| 1141 | func (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. |
| 1161 | func (m MatchHeaderRE) Provision(ctx caddy.Context) error { |