diff --git a/middleware/rewrite/rewrite.go b/middleware/rewrite/rewrite.go index c0447fbe..7d9793b2 100644 --- a/middleware/rewrite/rewrite.go +++ b/middleware/rewrite/rewrite.go @@ -13,12 +13,12 @@ import ( "github.com/mholt/caddy/middleware" ) -// RewriteResult is the result of a rewrite -type RewriteResult int +// Result is the result of a rewrite +type Result int const ( // RewriteIgnored is returned when rewrite is not done on request. - RewriteIgnored RewriteResult = iota + RewriteIgnored Result = iota // RewriteDone is returned when rewrite is done on request. RewriteDone // RewriteStatus is returned when rewrite is not needed and status code should be set @@ -55,7 +55,7 @@ outer: // Rule describes an internal location rewrite rule. type Rule interface { // Rewrite rewrites the internal location of the current request. - Rewrite(http.FileSystem, *http.Request) RewriteResult + Rewrite(http.FileSystem, *http.Request) Result } // SimpleRule is a simple rewrite rule. @@ -69,7 +69,7 @@ func NewSimpleRule(from, to string) SimpleRule { } // Rewrite rewrites the internal location of the current request. -func (s SimpleRule) Rewrite(fs http.FileSystem, r *http.Request) RewriteResult { +func (s SimpleRule) Rewrite(fs http.FileSystem, r *http.Request) Result { if s.From == r.URL.Path { // take note of this rewrite for internal use by fastcgi // all we need is the URI, not full URL @@ -136,7 +136,7 @@ func NewComplexRule(base, pattern, to string, status int, ext []string, ifs []If } // Rewrite rewrites the internal location of the current request. -func (r *ComplexRule) Rewrite(fs http.FileSystem, req *http.Request) (re RewriteResult) { +func (r *ComplexRule) Rewrite(fs http.FileSystem, req *http.Request) (re Result) { rPath := req.URL.Path replacer := newReplacer(req) diff --git a/middleware/rewrite/to.go b/middleware/rewrite/to.go index de07b7fb..7a38349f 100644 --- a/middleware/rewrite/to.go +++ b/middleware/rewrite/to.go @@ -13,7 +13,7 @@ import ( // To attempts rewrite. It attempts to rewrite to first valid path // or the last path if none of the paths are valid. // Returns true if rewrite is successful and false otherwise. -func To(fs http.FileSystem, r *http.Request, to string, replacer middleware.Replacer) RewriteResult { +func To(fs http.FileSystem, r *http.Request, to string, replacer middleware.Replacer) Result { tos := strings.Fields(to) // try each rewrite paths