We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 35af3d8 commit 1b332f3Copy full SHA for 1b332f3
serve.go
@@ -5,7 +5,11 @@ import "net/http"
5
6
// Options is a struct for specifying configuration options for a FileServer.
7
type Options struct {
8
+ // Directory is the root directory from which to serve files.
9
Directory string
10
+
11
+ // Prefix is a filepath prefix that should be ignored by the FileServer.
12
+ Prefix string
13
}
14
15
// FileServer wraps an http.FileServer.
@@ -27,7 +31,7 @@ func NewFileServer(options ...Options) *FileServer {
27
31
opt: opt,
28
32
29
33
30
- fs.handler = http.FileServer(http.Dir(opt.Directory))
34
+ fs.handler = http.StripPrefix(opt.Prefix, http.FileServer(http.Dir(opt.Directory)))
35
return fs
36
37
0 commit comments