Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
Tune AppConfigDir and docs for Storage module
Matthew Holt committed
Dec 31, 2019 at 18:31 UTC
06ea0a52950ef6d1dd327c10e247ada1b71a5c5d
2 files changed
+11
-13
caddy.go
+4
-5
@@ -61,11 +61,10 @@ type Config struct {
61
Logging *Logging `json:"logging,omitempty"`
62
63
// StorageRaw is a storage module that defines how/where Caddy
64
- // stores assets (such as TLS certificates). By default, this is
65
- // the local file system (`caddy.storage.file_system` module).
66
- // If the `XDG_DATA_HOME` environment variable is set, then
67
- // `$XDG_DATA_HOME/caddy` is the default folder. Otherwise,
68
- // `$HOME/.local/share/caddy` is the default folder.
64
+ // stores assets (such as TLS certificates). The default storage
65
+ // module is `caddy.storage.file_system` (the local file system),
66
+ // and the default path
67
+ // [depends on the OS and environment](/docs/conventions#data-directory).
68
StorageRaw json.RawMessage `json:"storage,omitempty" caddy:"namespace=caddy.storage inline_key=module"`
69
70
// AppsRaw are the apps that Caddy will load and run. The
storage.go
+7
-8
@@ -84,14 +84,13 @@ func homeDirUnsafe() string {
84
//
85
// Ref: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
86
func AppConfigDir() string {
87
- basedir := os.Getenv("XDG_CONFIG_HOME")
88
- if basedir == "" {
89
- var err error
90
- basedir, err = os.UserConfigDir()
91
- if err != nil {
92
- Log().Warn("unable to determine directory for user configuration; falling back to current directory", zap.Error(err))
93
- return "./caddy"
94
- }
87
+ if basedir := os.Getenv("XDG_CONFIG_HOME"); basedir != "" {
88
+ return filepath.Join(basedir, "caddy")
89
+ }
90
+ basedir, err := os.UserConfigDir()
91
+ if err != nil {
92
+ Log().Warn("unable to determine directory for user configuration; falling back to current directory", zap.Error(err))
93
+ return "./caddy"
94
}
95
subdir := "caddy"
96
switch runtime.GOOS {