Pipe and -conf flag together are an error (#315)

This commit is contained in:
Matthew Holt
2015-11-06 13:22:22 -07:00
parent cf5aa1bed1
commit 18e9aa4d57
2 changed files with 14 additions and 9 deletions

13
main.go
View File

@ -117,6 +117,19 @@ func mustLogFatal(args ...interface{}) {
}
func loadCaddyfile() (caddy.Input, error) {
// First try stdin pipe
cdyfile, err := caddy.CaddyfileFromPipe(os.Stdin)
if err != nil {
return nil, err
}
if cdyfile != nil {
// it is an error if -conf is also specified because, which to use?
if conf != "" {
return nil, errors.New("load: can't choose between stdin pipe and -conf flag")
}
return cdyfile, err
}
// -conf flag
if conf != "" {
contents, err := ioutil.ReadFile(conf)