1
0
mirror of https://github.com/labstack/echo.git synced 2025-11-27 22:38:25 +02:00
This commit is contained in:
Marcin Węglarz
2018-08-15 16:35:27 +02:00
committed by Vishal Rana
parent 2017e5e541
commit 74f9806b34
2 changed files with 35 additions and 1 deletions

View File

@@ -58,6 +58,7 @@ func RewriteWithConfig(config RewriteConfig) echo.MiddlewareFunc {
// Initialize
for k, v := range config.Rules {
k = strings.Replace(k, "*", "(.*)", -1)
k = k + "$"
config.rulesRegex[regexp.MustCompile(k)] = v
}
@@ -74,9 +75,9 @@ func RewriteWithConfig(config RewriteConfig) echo.MiddlewareFunc {
replacer := captureTokens(k, req.URL.Path)
if replacer != nil {
req.URL.Path = replacer.Replace(v)
break
}
}
return next(c)
}
}