Webserver runtime takes port as variable

This commit is contained in:
Layla 2021-01-28 08:02:13 -05:00
parent ac6f46345a
commit f17f3d160c
2 changed files with 3 additions and 3 deletions

View File

@ -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)

View File

@ -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))
}