Added ReplacePathRegex middleware

This commit is contained in:
Tiscs Sun 2017-10-30 19:54:03 +08:00 committed by Traefiker
parent e8633d17e8
commit 5042c5bf40
5 changed files with 138 additions and 0 deletions

View file

@ -92,6 +92,13 @@ func (r *Rules) replacePath(paths ...string) *mux.Route {
return r.route.route
}
func (r *Rules) replacePathRegex(paths ...string) *mux.Route {
for _, path := range paths {
r.route.replacePathRegex = path
}
return r.route.route
}
func (r *Rules) addPrefix(paths ...string) *mux.Route {
for _, path := range paths {
r.route.addPrefix = path
@ -155,6 +162,7 @@ func (r *Rules) parseRules(expression string, onRule func(functionName string, f
"HeadersRegexp": r.headersRegexp,
"AddPrefix": r.addPrefix,
"ReplacePath": r.replacePath,
"ReplacePathRegex": r.replacePathRegex,
"Query": r.query,
}