diff options
Diffstat (limited to 'modules/caddyhttp/rewrite')
| -rw-r--r-- | modules/caddyhttp/rewrite/caddyfile.go | 5 | ||||
| -rw-r--r-- | modules/caddyhttp/rewrite/rewrite.go | 19 | 
2 files changed, 2 insertions, 22 deletions
diff --git a/modules/caddyhttp/rewrite/caddyfile.go b/modules/caddyhttp/rewrite/caddyfile.go index 6674313..532df9a 100644 --- a/modules/caddyhttp/rewrite/caddyfile.go +++ b/modules/caddyhttp/rewrite/caddyfile.go @@ -44,7 +44,6 @@ func parseCaddyfileRewrite(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler,  			return nil, h.ArgErr()  		}  	} -	rewr.Rehandle = true  	return rewr, nil  } @@ -52,7 +51,7 @@ func parseCaddyfileRewrite(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler,  //  //     strip_prefix [<matcher>] <prefix>  // -// The request path will be stripped its prefix if it matches <prefix>. +// The request path will be stripped the given prefix.  func parseCaddyfileStripPrefix(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) {  	var rewr Rewrite  	for h.Next() { @@ -71,7 +70,7 @@ func parseCaddyfileStripPrefix(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHand  //  //     strip_suffix [<matcher>] <suffix>  // -// The request path will be stripped its suffix if it matches <suffix>. +// The request path will be stripped the given suffix.  func parseCaddyfileStripSuffix(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) {  	var rewr Rewrite  	for h.Next() { diff --git a/modules/caddyhttp/rewrite/rewrite.go b/modules/caddyhttp/rewrite/rewrite.go index b875adb..09478b8 100644 --- a/modules/caddyhttp/rewrite/rewrite.go +++ b/modules/caddyhttp/rewrite/rewrite.go @@ -15,7 +15,6 @@  package rewrite  import ( -	"fmt"  	"net/http"  	"net/url"  	"strconv" @@ -32,9 +31,6 @@ func init() {  // Rewrite is a middleware which can rewrite HTTP requests.  // -// The Rehandle and HTTPRedirect properties are mutually exclusive -// (you cannot both rehandle and issue a redirect). -//  // These rewrite properties are applied to a request in this order:  // Method, URI, StripPathPrefix, StripPathSuffix, URISubstring.  // @@ -61,10 +57,6 @@ type Rewrite struct {  	// given status code.  	HTTPRedirect caddyhttp.WeakString `json:"http_redirect,omitempty"` -	// If true, the request will sent for rehandling after rewriting -	// only if anything about the request was changed. -	Rehandle bool `json:"rehandle,omitempty"` -  	logger *zap.Logger  } @@ -82,14 +74,6 @@ func (rewr *Rewrite) Provision(ctx caddy.Context) error {  	return nil  } -// Validate ensures rewr's configuration is valid. -func (rewr Rewrite) Validate() error { -	if rewr.HTTPRedirect != "" && rewr.Rehandle { -		return fmt.Errorf("cannot be configured to both redirect externally and rehandle internally") -	} -	return nil -} -  func (rewr Rewrite) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {  	repl := r.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer) @@ -104,9 +88,6 @@ func (rewr Rewrite) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddy  			zap.String("method", r.Method),  			zap.String("uri", r.RequestURI),  		) -		if rewr.Rehandle { -			return caddyhttp.ErrRehandle -		}  		if rewr.HTTPRedirect != "" {  			statusCode, err := strconv.Atoi(repl.ReplaceAll(rewr.HTTPRedirect.String(), ""))  			if err != nil {  | 
