traefik/middlewares/redirect/redirect_regex.go
Gérald Croës a433e469cc SchemeRedirect Middleware
Co-authored-by: jbdoumenjou <jb.doumenjou@gmail.com>
2019-01-22 08:30:04 +01:00

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)
}