summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2015-11-03 08:10:16 -0700
committerMatthew Holt <[email protected]>2015-11-03 08:10:16 -0700
commite8006acf803afe40d2d490a0cbc27b0ed9f8b825 (patch)
treef761299620b326ba88c1f6929ba640ab3430cf6e
parent295d21f37de865164c08f9582b9c190abe374d4d (diff)
downloadcaddy-e8006acf803afe40d2d490a0cbc27b0ed9f8b825.tar.gz
caddy-e8006acf803afe40d2d490a0cbc27b0ed9f8b825.zip
Fix -port, -host, and -root flags when Caddyfile is missing
-rw-r--r--caddy/caddy.go7
-rw-r--r--caddy/config.go8
-rw-r--r--main.go2
3 files changed, 10 insertions, 7 deletions
diff --git a/caddy/caddy.go b/caddy/caddy.go
index f92666f02..81f8f0328 100644
--- a/caddy/caddy.go
+++ b/caddy/caddy.go
@@ -42,11 +42,6 @@ var (
// If true, initialization will not show any informative output.
Quiet bool
- // DefaultInput is the default configuration to use when config input is empty or missing.
- DefaultInput = CaddyfileInput{
- Contents: []byte(fmt.Sprintf("%s:%s\nroot %s", DefaultHost, DefaultPort, DefaultRoot)),
- }
-
// HTTP2 indicates whether HTTP2 is enabled or not
HTTP2 bool // TODO: temporary flag until http2 is standard
)
@@ -297,7 +292,7 @@ func LoadCaddyfile(loader func() (Input, error)) (cdyfile Input, err error) {
// Otherwise revert to default
if cdyfile == nil {
- cdyfile = DefaultInput
+ cdyfile = DefaultInput()
}
return
diff --git a/caddy/config.go b/caddy/config.go
index 0b14ca593..b7dfb146d 100644
--- a/caddy/config.go
+++ b/caddy/config.go
@@ -335,6 +335,14 @@ func NewDefault() server.Config {
}
}
+// DefaultInput returns the default Caddyfile input
+// to use when it is otherwise empty or missing.
+func DefaultInput() CaddyfileInput {
+ return CaddyfileInput{
+ Contents: []byte(fmt.Sprintf("%s:%s\nroot %s", Host, Port, Root)),
+ }
+}
+
// These defaults are configurable through the command line
var (
// Site root
diff --git a/main.go b/main.go
index 3c4930035..f28d6feb2 100644
--- a/main.go
+++ b/main.go
@@ -113,7 +113,7 @@ func loadCaddyfile() (caddy.Input, error) {
contents, err := ioutil.ReadFile(caddy.DefaultConfigFile)
if err != nil {
if os.IsNotExist(err) {
- return caddy.DefaultInput, nil
+ return caddy.DefaultInput(), nil
}
return nil, err
}