1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-07-14 01:57:32 +08:00

Introduce flag for TCP port

This commit is contained in:
Alex Ellis 2016-11-23 08:58:08 +00:00
parent fc9e4962d3
commit 11f2f48ebe

9
api.go
View File

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