Fix regex with PathStrip

This commit is contained in:
Stéphane Seguin 2017-03-24 12:07:59 +01:00 committed by Fernandez Ludovic
parent 74925ba996
commit bf3673879f
5 changed files with 156 additions and 17 deletions

View file

@ -62,10 +62,11 @@ type serverEntryPoint struct {
}
type serverRoute struct {
route *mux.Route
stripPrefixes []string
addPrefix string
replacePath string
route *mux.Route
stripPrefixes []string
stripPrefixesRegex []string
addPrefix string
replacePath string
}
// NewServer returns an initialized Server.
@ -807,6 +808,11 @@ func (server *Server) wireFrontendBackend(serverRoute *serverRoute, handler http
}
}
// strip prefix with regex
if len(serverRoute.stripPrefixesRegex) > 0 {
handler = middlewares.NewStripPrefixRegex(handler, serverRoute.stripPrefixesRegex)
}
// path replace
if len(serverRoute.replacePath) > 0 {
handler = &middlewares.ReplacePath{