mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-14 14:56:27 +03:00
cmd: file-server: add --access-log flag (#3454)
This commit is contained in:
parent
c1e5c09294
commit
aa20878887
1 changed files with 6 additions and 1 deletions
|
@ -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},
|
||||
|
|
Loading…
Reference in a new issue