mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 22:23:48 +03:00
using Matcher methods
This commit is contained in:
parent
acb5ff39d7
commit
cc34337b8e
1 changed files with 11 additions and 7 deletions
|
@ -132,15 +132,19 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhtt
|
||||||
// the requested destination/output value
|
// the requested destination/output value
|
||||||
for _, m := range h.Mappings {
|
for _, m := range h.Mappings {
|
||||||
if m.re != nil {
|
if m.re != nil {
|
||||||
if m.re.MatchString(input) {
|
matchRegexp := caddyhttp.MatchRegexp{Pattern: m.InputRegexp}
|
||||||
|
matchRegexp.Provision(caddy.Context{})
|
||||||
|
err := matchRegexp.Validate()
|
||||||
|
if err == nil {
|
||||||
|
if matchRegexp.Match(input, repl) {
|
||||||
if output := m.Outputs[destIdx]; output == nil {
|
if output := m.Outputs[destIdx]; output == nil {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
output = m.re.ReplaceAllString(input, m.Outputs[destIdx].(string))
|
output = repl.ReplaceAll(m.Outputs[destIdx].(string), "")
|
||||||
return output, true
|
return output, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue
|
}
|
||||||
}
|
}
|
||||||
if input == m.Input {
|
if input == m.Input {
|
||||||
if output := m.Outputs[destIdx]; output == nil {
|
if output := m.Outputs[destIdx]; output == nil {
|
||||||
|
|
Loading…
Reference in a new issue