0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

rewrite: Fix a lint suggestion

This commit is contained in:
Matthew Holt 2016-01-06 22:23:18 -07:00
parent ce4981d046
commit 93b301372b
2 changed files with 7 additions and 7 deletions

View file

@ -13,12 +13,12 @@ import (
"github.com/mholt/caddy/middleware" "github.com/mholt/caddy/middleware"
) )
// RewriteResult is the result of a rewrite // Result is the result of a rewrite
type RewriteResult int type Result int
const ( const (
// RewriteIgnored is returned when rewrite is not done on request. // 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 is returned when rewrite is done on request.
RewriteDone RewriteDone
// RewriteStatus is returned when rewrite is not needed and status code should be set // 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. // Rule describes an internal location rewrite rule.
type Rule interface { type Rule interface {
// Rewrite rewrites the internal location of the current request. // 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. // 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. // 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 { if s.From == r.URL.Path {
// take note of this rewrite for internal use by fastcgi // take note of this rewrite for internal use by fastcgi
// all we need is the URI, not full URL // 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. // 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 rPath := req.URL.Path
replacer := newReplacer(req) replacer := newReplacer(req)

View file

@ -13,7 +13,7 @@ import (
// To attempts rewrite. It attempts to rewrite to first valid path // To attempts rewrite. It attempts to rewrite to first valid path
// or the last path if none of the paths are valid. // or the last path if none of the paths are valid.
// Returns true if rewrite is successful and false otherwise. // 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) tos := strings.Fields(to)
// try each rewrite paths // try each rewrite paths