diff --git a/api.go b/api.go index 9a909fc..c75d765 100644 --- a/api.go +++ b/api.go @@ -10,10 +10,16 @@ import ( "github.com/franela/play-with-docker/templates" "github.com/gorilla/mux" "github.com/urfave/negroni" + "flag" + "strconv" ) func main() { + var portNumber int + flag.IntVar(&portNumber, "port", 3000, "Give a TCP port to run the application") + flag.Parse() + welcome, tmplErr := templates.GetWelcomeTemplate() if tmplErr != nil { log.Fatal(tmplErr) @@ -56,6 +62,7 @@ func main() { n := negroni.Classic() n.UseHandler(r) - log.Fatal(http.ListenAndServe("0.0.0.0:3000", n)) + log.Println("Listening on port "+ strconv.Itoa(portNumber)) + log.Fatal(http.ListenAndServe("0.0.0.0:"+strconv.Itoa(portNumber), n)) }