a433e469cc
Co-authored-by: jbdoumenjou <jb.doumenjou@gmail.com>
22 lines
627 B
Go
22 lines
627 B
Go
package redirect
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/containous/traefik/config"
|
|
"github.com/containous/traefik/middlewares"
|
|
)
|
|
|
|
const (
|
|
typeRegexName = "RedirectRegex"
|
|
)
|
|
|
|
// NewRedirectRegex creates a redirect middleware.
|
|
func NewRedirectRegex(ctx context.Context, next http.Handler, conf config.RedirectRegex, name string) (http.Handler, error) {
|
|
logger := middlewares.GetLogger(ctx, name, typeRegexName)
|
|
logger.Debug("Creating middleware")
|
|
logger.Debugf("Setting up redirection from %s to %s", conf.Regex, conf.Replacement)
|
|
|
|
return newRedirect(ctx, next, conf.Regex, conf.Replacement, conf.Permanent, name)
|
|
}
|