diff options
author | Emile <hanemile@protonmail.com> | 2020-01-27 20:28:05 +0100 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2020-01-27 20:28:05 +0100 |
commit | 0b34876f2b17f8cefcb4192b44f1f8139cf52818 (patch) | |
tree | 0e180a10053c36396387b61942549fa4de63216f | |
parent | a0962a4248ef055651cd358d56f6173deb20c289 (diff) |
implemented the config struct
-rw-r--r-- | src/main.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main.go b/src/main.go index 74f8f51..5a6d851 100644 --- a/src/main.go +++ b/src/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "log" "net/http" @@ -22,10 +23,14 @@ func main() { // create a cities map mapping a city to a location cities = make(map[string]location) + // parse flags building a config struct + config := parseFlags() + // start the ssh server log.Println("Starting SSH listener") go func() { - listenErr := ssh.ListenAndServe(":2222", nil, ssh.PasswordAuth(handlePass)) + sshPortString := fmt.Sprintf(":%d", config.sshPort) + listenErr := ssh.ListenAndServe(sshPortString, nil, ssh.PasswordAuth(handlePass)) if listenErr != nil { log.Fatalln(listenErr.Error()) } @@ -40,7 +45,8 @@ func main() { r.HandleFunc("/locations", locationHandlerEndpoint) // start the http server exposing the metrics and the locations - listenErr := http.ListenAndServe(":8084", r) + httpPortString := fmt.Sprintf(":%d", config.httpPort) + listenErr := http.ListenAndServe(httpPortString, r) // handle potential errors if listenErr != nil { |