From a5d66842ed3ec5482fc37ca804cca9cb8b898f06 Mon Sep 17 00:00:00 2001 From: Kesuaheli Date: Thu, 26 Dec 2024 18:06:00 +0100 Subject: [PATCH] chore(Config): addedn configurable webserver host and port --- config.yaml | 5 +++++ main.go | 3 +-- webserver/main.go | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/config.yaml b/config.yaml index e4da7ed..2694619 100644 --- a/config.yaml +++ b/config.yaml @@ -110,6 +110,11 @@ event: #animated: true webserver: + # The host on which the webserver is bound to + #host: + # The port on which the webserver listens + port: 8080 + # The path to the favicon for the webserver favicon: webserver/favicon.png twitch: diff --git a/main.go b/main.go index 04730f1..eb86467 100644 --- a/main.go +++ b/main.go @@ -100,8 +100,7 @@ func main() { } log.Println("Starting webserver...") - addr := ":8080" - webserver.Run(addr, webChan) + webserver.Run(webChan) // Wait to end the bot log.Println("Press Ctrl+C to exit") diff --git a/webserver/main.go b/webserver/main.go index d8d193e..f9172d4 100644 --- a/webserver/main.go +++ b/webserver/main.go @@ -18,6 +18,7 @@ import ( "cake4everybot/webserver/twitch" "cake4everybot/webserver/youtube" logger "log" + "net" "net/http" "time" @@ -42,9 +43,10 @@ func initHTTP() http.Handler { } // Run starts the webserver at the given address -func Run(addr string, webChan chan struct{}) { +func Run(webChan chan struct{}) { handler := initHTTP() + var addr string = net.JoinHostPort(viper.GetString("webserver.host"), viper.GetString("webserver.port")) var err error go func() {