Remove deprecated options
This commit is contained in:
parent
bee86b5ac7
commit
a3e4c85ec0
62 changed files with 43 additions and 985 deletions
|
@ -19,20 +19,18 @@ const (
|
|||
|
||||
// stripPrefix is a middleware used to strip prefix from an URL request.
|
||||
type stripPrefix struct {
|
||||
next http.Handler
|
||||
prefixes []string
|
||||
forceSlash bool // TODO Must be removed (breaking), the default behavior must be forceSlash=false
|
||||
name string
|
||||
next http.Handler
|
||||
prefixes []string
|
||||
name string
|
||||
}
|
||||
|
||||
// New creates a new strip prefix middleware.
|
||||
func New(ctx context.Context, next http.Handler, config dynamic.StripPrefix, name string) (http.Handler, error) {
|
||||
middlewares.GetLogger(ctx, name, typeName).Debug().Msg("Creating middleware")
|
||||
return &stripPrefix{
|
||||
prefixes: config.Prefixes,
|
||||
forceSlash: config.ForceSlash,
|
||||
next: next,
|
||||
name: name,
|
||||
prefixes: config.Prefixes,
|
||||
next: next,
|
||||
name: name,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -61,13 +59,6 @@ func (s *stripPrefix) serveRequest(rw http.ResponseWriter, req *http.Request, pr
|
|||
}
|
||||
|
||||
func (s *stripPrefix) getPrefixStripped(urlPath, prefix string) string {
|
||||
if s.forceSlash {
|
||||
// Only for compatibility reason with the previous behavior,
|
||||
// but the previous behavior is wrong.
|
||||
// This needs to be removed in the next breaking version.
|
||||
return "/" + strings.TrimPrefix(strings.TrimPrefix(urlPath, prefix), "/")
|
||||
}
|
||||
|
||||
return ensureLeadingSlash(strings.TrimPrefix(urlPath, prefix))
|
||||
}
|
||||
|
||||
|
|
|
@ -31,17 +31,6 @@ func TestStripPrefix(t *testing.T) {
|
|||
expectedStatusCode: http.StatusOK,
|
||||
expectedPath: "/noprefixes",
|
||||
},
|
||||
{
|
||||
desc: "wildcard (.*) requests (ForceSlash)",
|
||||
config: dynamic.StripPrefix{
|
||||
Prefixes: []string{"/"},
|
||||
ForceSlash: true,
|
||||
},
|
||||
path: "/",
|
||||
expectedStatusCode: http.StatusOK,
|
||||
expectedPath: "/",
|
||||
expectedHeader: "/",
|
||||
},
|
||||
{
|
||||
desc: "wildcard (.*) requests",
|
||||
config: dynamic.StripPrefix{
|
||||
|
@ -52,17 +41,6 @@ func TestStripPrefix(t *testing.T) {
|
|||
expectedPath: "",
|
||||
expectedHeader: "/",
|
||||
},
|
||||
{
|
||||
desc: "prefix and path matching (ForceSlash)",
|
||||
config: dynamic.StripPrefix{
|
||||
Prefixes: []string{"/stat"},
|
||||
ForceSlash: true,
|
||||
},
|
||||
path: "/stat",
|
||||
expectedStatusCode: http.StatusOK,
|
||||
expectedPath: "/",
|
||||
expectedHeader: "/stat",
|
||||
},
|
||||
{
|
||||
desc: "prefix and path matching",
|
||||
config: dynamic.StripPrefix{
|
||||
|
@ -73,17 +51,6 @@ func TestStripPrefix(t *testing.T) {
|
|||
expectedPath: "",
|
||||
expectedHeader: "/stat",
|
||||
},
|
||||
{
|
||||
desc: "path prefix on exactly matching path (ForceSlash)",
|
||||
config: dynamic.StripPrefix{
|
||||
Prefixes: []string{"/stat/"},
|
||||
ForceSlash: true,
|
||||
},
|
||||
path: "/stat/",
|
||||
expectedStatusCode: http.StatusOK,
|
||||
expectedPath: "/",
|
||||
expectedHeader: "/stat/",
|
||||
},
|
||||
{
|
||||
desc: "path prefix on exactly matching path",
|
||||
config: dynamic.StripPrefix{
|
||||
|
@ -133,17 +100,6 @@ func TestStripPrefix(t *testing.T) {
|
|||
expectedPath: "/us",
|
||||
expectedHeader: "/stat",
|
||||
},
|
||||
{
|
||||
desc: "later prefix matching (ForceSlash)",
|
||||
config: dynamic.StripPrefix{
|
||||
Prefixes: []string{"/mismatch", "/stat"},
|
||||
ForceSlash: true,
|
||||
},
|
||||
path: "/stat",
|
||||
expectedStatusCode: http.StatusOK,
|
||||
expectedPath: "/",
|
||||
expectedHeader: "/stat",
|
||||
},
|
||||
{
|
||||
desc: "later prefix matching",
|
||||
config: dynamic.StripPrefix{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue