Webserver runtime takes port as variable
This commit is contained in:
parent
ac6f46345a
commit
f17f3d160c
2
main.go
2
main.go
@ -43,7 +43,7 @@ func main() {
|
|||||||
|
|
||||||
switch appRuntime {
|
switch appRuntime {
|
||||||
case "webserver":
|
case "webserver":
|
||||||
runtime.StartWebserver()
|
runtime.StartWebserver(8081)
|
||||||
default:
|
default:
|
||||||
log.Fatalln("Runtime is currently not implemented!")
|
log.Fatalln("Runtime is currently not implemented!")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -48,9 +48,9 @@ func getCharacter(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StartWebserver starts the webserver
|
// StartWebserver starts the webserver
|
||||||
func StartWebserver() {
|
func StartWebserver(port int) {
|
||||||
myRouter := mux.NewRouter().StrictSlash(true)
|
myRouter := mux.NewRouter().StrictSlash(true)
|
||||||
myRouter.HandleFunc("/health", healthCheck)
|
myRouter.HandleFunc("/health", healthCheck)
|
||||||
myRouter.HandleFunc("/get/character/{user}/{char}", getCharacter)
|
myRouter.HandleFunc("/get/character/{user}/{char}", getCharacter)
|
||||||
log.Fatal(http.ListenAndServe(":8081", myRouter))
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), myRouter))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user