1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

Fixed behavior with empty Caddyfile

If the -host flag is used, we might still have to set up Let's Encrypt, so this change is necessary.
This commit is contained in:
Matthew Holt 2015-11-04 09:26:11 -07:00
parent 7f7a6abafd
commit 051d2a68c0

View file

@ -1,6 +1,7 @@
package caddy
import (
"bytes"
"fmt"
"io"
"log"
@ -39,7 +40,11 @@ func loadConfigs(filename string, input io.Reader) ([]server.Config, error) {
return nil, err
}
if len(serverBlocks) == 0 {
return []server.Config{NewDefault()}, nil
newInput := DefaultInput()
serverBlocks, err = parse.ServerBlocks(newInput.Path(), bytes.NewReader(newInput.Body()), true)
if err != nil {
return nil, err
}
}
var lastDirectiveIndex int // we set up directives in two parts; this stores where we left off