summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/fileserver
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2019-07-11 15:32:34 -0600
committerGitHub <noreply@github.com>2019-07-11 15:32:34 -0600
commit9343403358bd34b787a209b41c5b820781f78890 (patch)
tree559461c6504b7c1be38e0ddfbf0793b473ef8d66 /modules/caddyhttp/fileserver
parent6dfba5fda82e216cffb117a62fcefbe61cd25a34 (diff)
Flatten HTTP handler config (#2662) (#2663)
Differentiating middleware and responders has one benefit, namely that it's clear which module provides the response, but even then it's not a great advantage. Linear handler config makes a little more sense, giving greater flexibility and simplifying the core a bit, even though it's slightly awkward that handlers which are responders may not use the 'next' handler that is passed in at all.
Diffstat (limited to 'modules/caddyhttp/fileserver')
-rw-r--r--modules/caddyhttp/fileserver/staticfiles.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/modules/caddyhttp/fileserver/staticfiles.go b/modules/caddyhttp/fileserver/staticfiles.go
index 0bb910d..a7c72c9 100644
--- a/modules/caddyhttp/fileserver/staticfiles.go
+++ b/modules/caddyhttp/fileserver/staticfiles.go
@@ -35,7 +35,7 @@ func init() {
weakrand.Seed(time.Now().UnixNano())
caddy.RegisterModule(caddy.Module{
- Name: "http.responders.file_server",
+ Name: "http.handlers.file_server",
New: func() interface{} { return new(FileServer) },
})
}
@@ -108,7 +108,7 @@ func (fsrv *FileServer) Validate() error {
return nil
}
-func (fsrv *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) error {
+func (fsrv *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request, _ caddyhttp.Handler) error {
repl := r.Context().Value(caddy.ReplacerCtxKey).(caddy.Replacer)
filesToHide := fsrv.transformHidePaths(repl)
@@ -119,7 +119,7 @@ func (fsrv *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) error
if filename == "" {
// no files worked, so resort to fallback
if fsrv.Fallback != nil {
- fallback, w := fsrv.Fallback.BuildCompositeRoute(w, r)
+ fallback := fsrv.Fallback.BuildCompositeRoute(w, r)
return fallback.ServeHTTP(w, r)
}
return caddyhttp.Error(http.StatusNotFound, nil)
@@ -452,7 +452,7 @@ const minBackoff, maxBackoff = 2, 5
// Interface guards
var (
- _ caddy.Provisioner = (*FileServer)(nil)
- _ caddy.Validator = (*FileServer)(nil)
- _ caddyhttp.Handler = (*FileServer)(nil)
+ _ caddy.Provisioner = (*FileServer)(nil)
+ _ caddy.Validator = (*FileServer)(nil)
+ _ caddyhttp.MiddlewareHandler = (*FileServer)(nil)
)