diff options
author | Matt Holt <mholt@users.noreply.github.com> | 2022-07-30 13:07:44 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-30 13:07:44 -0600 |
commit | 6668271661857b2cc43143ff65edf1071013e67e (patch) | |
tree | 347a2b46e9c36c4af0f68a660821546c25e6441a /modules/caddyhttp/fileserver/matcher_test.go | |
parent | 07ed3e7c3078723b55687bf4b262d24ef1645c7d (diff) |
fileserver: Support virtual file systems (#4909)
* fileserver: Support virtual file systems (close #3720)
This change replaces the hard-coded use of os.Open() and os.Stat() with
the use of the new (Go 1.16) io/fs APIs, enabling virtual file systems.
It introduces a new module namespace, caddy.fs, for such file systems.
Also improve documentation for the file server. I realized it was one of
the first modules written for Caddy 2, and the docs hadn't really been
updated since!
* Virtualize FS for file matcher; minor tweaks
* Fix tests and rename dirFS -> osFS
(Since we do not use a root directory, it is dynamic.)
Diffstat (limited to 'modules/caddyhttp/fileserver/matcher_test.go')
-rw-r--r-- | modules/caddyhttp/fileserver/matcher_test.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/modules/caddyhttp/fileserver/matcher_test.go b/modules/caddyhttp/fileserver/matcher_test.go index fd109e6..7734bf1 100644 --- a/modules/caddyhttp/fileserver/matcher_test.go +++ b/modules/caddyhttp/fileserver/matcher_test.go @@ -111,8 +111,9 @@ func TestFileMatcher(t *testing.T) { }, } { m := &MatchFile{ - Root: "./testdata", - TryFiles: []string{"{http.request.uri.path}", "{http.request.uri.path}/"}, + fileSystem: osFS{}, + Root: "./testdata", + TryFiles: []string{"{http.request.uri.path}", "{http.request.uri.path}/"}, } u, err := url.Parse(tc.path) @@ -213,9 +214,10 @@ func TestPHPFileMatcher(t *testing.T) { }, } { m := &MatchFile{ - Root: "./testdata", - TryFiles: []string{"{http.request.uri.path}", "{http.request.uri.path}/index.php"}, - SplitPath: []string{".php"}, + fileSystem: osFS{}, + Root: "./testdata", + TryFiles: []string{"{http.request.uri.path}", "{http.request.uri.path}/index.php"}, + SplitPath: []string{".php"}, } u, err := url.Parse(tc.path) |