From de9cf14a68c3d0a2e8d14c8b7c4cc431feedfe08 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Fri, 10 Dec 2021 13:21:32 -0500 Subject: [PATCH] Honor the host and port settings in the YAML config Note that precedence will be given to the environment variables. Fixes #38. --- server/server.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server/server.go b/server/server.go index e7ab0cf23e23fd31119af8569ecc473df9c1960a..55916296144af06c398c1921fd972af28773e7d2 100644 --- a/server/server.go +++ b/server/server.go @@ -32,6 +32,17 @@ func NewServer(cfg *config.Config) *Server { if err != nil { log.Fatal(err) } + + // If the host and port are set in config.yaml, and they weren't set in the + // environment, update the environment level config accordingly, which is + // the config used to start the server. + if cfg.Host == "" { + cfg.Host = ac.Host + } + if cfg.Port == 0 { + cfg.Port = ac.Port + } + mw := []wish.Middleware{ bm.Middleware(tui.SessionHandler(ac)), gm.Middleware(cfg.RepoPath, ac),