summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Lopes <rgl@ruilopes.com>2020-05-26 22:04:04 +0100
committerGitHub <noreply@github.com>2020-05-26 15:04:04 -0600
commitaa20878887c592fd79bef2a9943b1013ead8bac2 (patch)
tree457a1399dc69f5f26f44253e8a1d97dcd01fd270
parentc1e5c09294abdb01bb404aafced7c9092b202070 (diff)
cmd: file-server: add --access-log flag (#3454)
-rw-r--r--modules/caddyhttp/fileserver/command.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/caddyhttp/fileserver/command.go b/modules/caddyhttp/fileserver/command.go
index 6a44b3c..654c9b8 100644
--- a/modules/caddyhttp/fileserver/command.go
+++ b/modules/caddyhttp/fileserver/command.go
@@ -33,7 +33,7 @@ func init() {
caddycmd.RegisterCommand(caddycmd.Command{
Name: "file-server",
Func: cmdFileServer,
- Usage: "[--domain <example.com>] [--root <path>] [--listen <addr>] [--browse]",
+ Usage: "[--domain <example.com>] [--root <path>] [--listen <addr>] [--browse] [--access-log]",
Short: "Spins up a production-ready file server",
Long: `
A simple but production-ready file server. Useful for quick deployments,
@@ -55,6 +55,7 @@ respond with a file listing.`,
fs.String("listen", "", "The address to which to bind the listener")
fs.Bool("browse", false, "Enable directory browsing")
fs.Bool("templates", false, "Enable template rendering")
+ fs.Bool("access-log", false, "Enable the access log")
return fs
}(),
})
@@ -68,6 +69,7 @@ func cmdFileServer(fs caddycmd.Flags) (int, error) {
listen := fs.String("listen")
browse := fs.Bool("browse")
templates := fs.Bool("templates")
+ accessLog := fs.Bool("access-log")
var handlers []json.RawMessage
@@ -107,6 +109,9 @@ func cmdFileServer(fs caddycmd.Flags) (int, error) {
}
}
server.Listen = []string{listen}
+ if accessLog {
+ server.Logs = &caddyhttp.ServerLogConfig{}
+ }
httpApp := caddyhttp.App{
Servers: map[string]*caddyhttp.Server{"static": server},