mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-22 12:28:45 +08:00
Tune AppConfigDir and docs for Storage module
This commit is contained in:
parent
788462bd4c
commit
06ea0a5295
9
caddy.go
9
caddy.go
|
@ -61,11 +61,10 @@ type Config struct {
|
||||||
Logging *Logging `json:"logging,omitempty"`
|
Logging *Logging `json:"logging,omitempty"`
|
||||||
|
|
||||||
// StorageRaw is a storage module that defines how/where Caddy
|
// StorageRaw is a storage module that defines how/where Caddy
|
||||||
// stores assets (such as TLS certificates). By default, this is
|
// stores assets (such as TLS certificates). The default storage
|
||||||
// the local file system (`caddy.storage.file_system` module).
|
// module is `caddy.storage.file_system` (the local file system),
|
||||||
// If the `XDG_DATA_HOME` environment variable is set, then
|
// and the default path
|
||||||
// `$XDG_DATA_HOME/caddy` is the default folder. Otherwise,
|
// [depends on the OS and environment](/docs/conventions#data-directory).
|
||||||
// `$HOME/.local/share/caddy` is the default folder.
|
|
||||||
StorageRaw json.RawMessage `json:"storage,omitempty" caddy:"namespace=caddy.storage inline_key=module"`
|
StorageRaw json.RawMessage `json:"storage,omitempty" caddy:"namespace=caddy.storage inline_key=module"`
|
||||||
|
|
||||||
// AppsRaw are the apps that Caddy will load and run. The
|
// AppsRaw are the apps that Caddy will load and run. The
|
||||||
|
|
15
storage.go
15
storage.go
|
@ -84,14 +84,13 @@ func homeDirUnsafe() string {
|
||||||
//
|
//
|
||||||
// Ref: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
// Ref: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||||
func AppConfigDir() string {
|
func AppConfigDir() string {
|
||||||
basedir := os.Getenv("XDG_CONFIG_HOME")
|
if basedir := os.Getenv("XDG_CONFIG_HOME"); basedir != "" {
|
||||||
if basedir == "" {
|
return filepath.Join(basedir, "caddy")
|
||||||
var err error
|
}
|
||||||
basedir, err = os.UserConfigDir()
|
basedir, err := os.UserConfigDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Log().Warn("unable to determine directory for user configuration; falling back to current directory", zap.Error(err))
|
Log().Warn("unable to determine directory for user configuration; falling back to current directory", zap.Error(err))
|
||||||
return "./caddy"
|
return "./caddy"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
subdir := "caddy"
|
subdir := "caddy"
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user