summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/fileserver
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/fileserver')
-rw-r--r--modules/caddyhttp/fileserver/browse.go8
-rw-r--r--modules/caddyhttp/fileserver/browselisting.go4
-rw-r--r--modules/caddyhttp/fileserver/matcher.go6
-rw-r--r--modules/caddyhttp/fileserver/staticfiles.go14
4 files changed, 16 insertions, 16 deletions
diff --git a/modules/caddyhttp/fileserver/browse.go b/modules/caddyhttp/fileserver/browse.go
index d86bc64..1329541 100644
--- a/modules/caddyhttp/fileserver/browse.go
+++ b/modules/caddyhttp/fileserver/browse.go
@@ -9,8 +9,8 @@ import (
"path"
"strings"
- "github.com/caddyserver/caddy2"
- "github.com/caddyserver/caddy2/modules/caddyhttp"
+ "github.com/caddyserver/caddy"
+ "github.com/caddyserver/caddy/modules/caddyhttp"
)
// Browse configures directory browsing.
@@ -37,7 +37,7 @@ func (fsrv *FileServer) serveBrowse(dirPath string, w http.ResponseWriter, r *ht
}
defer dir.Close()
- repl := r.Context().Value(caddy2.ReplacerCtxKey).(caddy2.Replacer)
+ repl := r.Context().Value(caddy.ReplacerCtxKey).(caddy.Replacer)
// calling path.Clean here prevents weird breadcrumbs when URL paths are sketchy like /%2e%2e%2f
listing, err := fsrv.loadDirectoryContents(dir, path.Clean(r.URL.Path), repl)
@@ -71,7 +71,7 @@ func (fsrv *FileServer) serveBrowse(dirPath string, w http.ResponseWriter, r *ht
return nil
}
-func (fsrv *FileServer) loadDirectoryContents(dir *os.File, urlPath string, repl caddy2.Replacer) (browseListing, error) {
+func (fsrv *FileServer) loadDirectoryContents(dir *os.File, urlPath string, repl caddy.Replacer) (browseListing, error) {
files, err := dir.Readdir(-1)
if err != nil {
return browseListing{}, err
diff --git a/modules/caddyhttp/fileserver/browselisting.go b/modules/caddyhttp/fileserver/browselisting.go
index ba915bf..eb0ec97 100644
--- a/modules/caddyhttp/fileserver/browselisting.go
+++ b/modules/caddyhttp/fileserver/browselisting.go
@@ -9,11 +9,11 @@ import (
"strings"
"time"
- "github.com/caddyserver/caddy2"
+ "github.com/caddyserver/caddy"
"github.com/dustin/go-humanize"
)
-func (fsrv *FileServer) directoryListing(files []os.FileInfo, canGoUp bool, urlPath string, repl caddy2.Replacer) browseListing {
+func (fsrv *FileServer) directoryListing(files []os.FileInfo, canGoUp bool, urlPath string, repl caddy.Replacer) browseListing {
filesToHide := fsrv.transformHidePaths(repl)
var (
diff --git a/modules/caddyhttp/fileserver/matcher.go b/modules/caddyhttp/fileserver/matcher.go
index 0bdbf67..ff4321a 100644
--- a/modules/caddyhttp/fileserver/matcher.go
+++ b/modules/caddyhttp/fileserver/matcher.go
@@ -4,12 +4,12 @@ import (
"net/http"
"os"
- "github.com/caddyserver/caddy2"
- "github.com/caddyserver/caddy2/modules/caddyhttp"
+ "github.com/caddyserver/caddy"
+ "github.com/caddyserver/caddy/modules/caddyhttp"
)
func init() {
- caddy2.RegisterModule(caddy2.Module{
+ caddy.RegisterModule(caddy.Module{
Name: "http.matchers.file",
New: func() interface{} { return new(FileMatcher) },
})
diff --git a/modules/caddyhttp/fileserver/staticfiles.go b/modules/caddyhttp/fileserver/staticfiles.go
index d094406..080e1a8 100644
--- a/modules/caddyhttp/fileserver/staticfiles.go
+++ b/modules/caddyhttp/fileserver/staticfiles.go
@@ -12,14 +12,14 @@ import (
"strings"
"time"
- "github.com/caddyserver/caddy2"
- "github.com/caddyserver/caddy2/modules/caddyhttp"
+ "github.com/caddyserver/caddy"
+ "github.com/caddyserver/caddy/modules/caddyhttp"
)
func init() {
weakrand.Seed(time.Now().UnixNano())
- caddy2.RegisterModule(caddy2.Module{
+ caddy.RegisterModule(caddy.Module{
Name: "http.responders.file_server",
New: func() interface{} { return new(FileServer) },
})
@@ -40,7 +40,7 @@ type FileServer struct {
}
// Provision sets up the static files responder.
-func (fsrv *FileServer) Provision(ctx caddy2.Context) error {
+func (fsrv *FileServer) Provision(ctx caddy.Context) error {
if fsrv.Fallback != nil {
err := fsrv.Fallback.Provision(ctx)
if err != nil {
@@ -94,7 +94,7 @@ func (fsrv *FileServer) Validate() error {
}
func (fsrv *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) error {
- repl := r.Context().Value(caddy2.ReplacerCtxKey).(caddy2.Replacer)
+ repl := r.Context().Value(caddy.ReplacerCtxKey).(caddy.Replacer)
filesToHide := fsrv.transformHidePaths(repl)
@@ -251,7 +251,7 @@ func mapDirOpenError(originalErr error, name string) error {
// transformHidePaths performs replacements for all the elements of
// fsrv.Hide and returns a new list of the transformed values.
-func (fsrv *FileServer) transformHidePaths(repl caddy2.Replacer) []string {
+func (fsrv *FileServer) transformHidePaths(repl caddy.Replacer) []string {
hide := make([]string, len(fsrv.Hide))
for i := range fsrv.Hide {
hide[i] = repl.ReplaceAll(fsrv.Hide[i], "")
@@ -288,7 +288,7 @@ func sanitizedPathJoin(root, reqPath string) string {
// by default) to map the request r to a filename. The full path to
// the file is returned if one is found; otherwise, an empty string
// is returned.
-func (fsrv *FileServer) selectFile(r *http.Request, repl caddy2.Replacer, filesToHide []string) string {
+func (fsrv *FileServer) selectFile(r *http.Request, repl caddy.Replacer, filesToHide []string) string {
root := repl.ReplaceAll(fsrv.Root, "")
if fsrv.Files == nil {