mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-05 18:44:58 +03:00
Merge pull request #234 from humboldtux/browse
core: Configuration as command line arg #222
This commit is contained in:
commit
f8e2cc8008
1 changed files with 7 additions and 1 deletions
8
main.go
8
main.go
|
@ -124,7 +124,7 @@ func isLocalhost(s string) bool {
|
||||||
// loadConfigs loads configuration from a file or stdin (piped).
|
// loadConfigs loads configuration from a file or stdin (piped).
|
||||||
// The configurations are grouped by bind address.
|
// The configurations are grouped by bind address.
|
||||||
// Configuration is obtained from one of three sources, tried
|
// Configuration is obtained from one of three sources, tried
|
||||||
// in this order: 1. -conf flag, 2. stdin, 3. Caddyfile.
|
// in this order: 1. -conf flag, 2. stdin, 3. command line argument 4. Caddyfile.
|
||||||
// If none of those are available, a default configuration is
|
// If none of those are available, a default configuration is
|
||||||
// loaded.
|
// loaded.
|
||||||
func loadConfigs() (config.Group, error) {
|
func loadConfigs() (config.Group, error) {
|
||||||
|
@ -155,6 +155,12 @@ func loadConfigs() (config.Group, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Command line Arg
|
||||||
|
if flag.NArg() > 0 {
|
||||||
|
confBody := ":" + config.DefaultPort + "\n" + strings.Join(flag.Args(), "\n")
|
||||||
|
return config.Load("args", bytes.NewBufferString(confBody))
|
||||||
|
}
|
||||||
|
|
||||||
// Caddyfile
|
// Caddyfile
|
||||||
file, err := os.Open(config.DefaultConfigFile)
|
file, err := os.Open(config.DefaultConfigFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue