From f17f3d160c3bf664e60756f7adeb52298c77ff4e Mon Sep 17 00:00:00 2001 From: Joseph Manley Date: Thu, 28 Jan 2021 08:02:13 -0500 Subject: [PATCH] Webserver runtime takes port as variable --- main.go | 2 +- runtime/webserver.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 0defc5d..a7f172d 100644 --- a/main.go +++ b/main.go @@ -43,7 +43,7 @@ func main() { switch appRuntime { case "webserver": - runtime.StartWebserver() + runtime.StartWebserver(8081) default: log.Fatalln("Runtime is currently not implemented!") os.Exit(1) diff --git a/runtime/webserver.go b/runtime/webserver.go index 87eeaa3..423d32e 100644 --- a/runtime/webserver.go +++ b/runtime/webserver.go @@ -48,9 +48,9 @@ func getCharacter(w http.ResponseWriter, r *http.Request) { } // StartWebserver starts the webserver -func StartWebserver() { +func StartWebserver(port int) { myRouter := mux.NewRouter().StrictSlash(true) myRouter.HandleFunc("/health", healthCheck) myRouter.HandleFunc("/get/character/{user}/{char}", getCharacter) - log.Fatal(http.ListenAndServe(":8081", myRouter)) + log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), myRouter)) }