de9cf14a68c3d0a2e8d14c8b7c4cc431feedfe08

Author
Christian Rocha <christian@rocha.is>
Committer
Christian Rocha <christian@rocha.is>
Date

Message

Honor the host and port settings in the YAML config

Note that precedence will be given to the environment variables.

Fixes #38.

Diff

 1diff --git a/server/server.go b/server/server.go
 2index e7ab0cf23e23fd31119af8569ecc473df9c1960a..55916296144af06c398c1921fd972af28773e7d2 100644
 3--- a/server/server.go
 4+++ b/server/server.go
 5@@ -32,6 +32,17 @@ func NewServer(cfg *config.Config) *Server {
 6 	if err != nil {
 7 		log.Fatal(err)
 8 	}
 9+
10+	// If the host and port are set in config.yaml, and they weren't set in the
11+	// environment, update the environment level config accordingly, which is
12+	// the config used to start the server.
13+	if cfg.Host == "" {
14+		cfg.Host = ac.Host
15+	}
16+	if cfg.Port == 0 {
17+		cfg.Port = ac.Port
18+	}
19+
20 	mw := []wish.Middleware{
21 		bm.Middleware(tui.SessionHandler(ac)),
22 		gm.Middleware(cfg.RepoPath, ac),