mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-15 02:37:27 +08:00
Introduce flag for TCP port
This commit is contained in:
parent
fc9e4962d3
commit
11f2f48ebe
9
api.go
9
api.go
@ -10,10 +10,16 @@ import (
|
|||||||
"github.com/franela/play-with-docker/templates"
|
"github.com/franela/play-with-docker/templates"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/urfave/negroni"
|
"github.com/urfave/negroni"
|
||||||
|
"flag"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
var portNumber int
|
||||||
|
flag.IntVar(&portNumber, "port", 3000, "Give a TCP port to run the application")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
welcome, tmplErr := templates.GetWelcomeTemplate()
|
welcome, tmplErr := templates.GetWelcomeTemplate()
|
||||||
if tmplErr != nil {
|
if tmplErr != nil {
|
||||||
log.Fatal(tmplErr)
|
log.Fatal(tmplErr)
|
||||||
@ -56,6 +62,7 @@ func main() {
|
|||||||
n := negroni.Classic()
|
n := negroni.Classic()
|
||||||
n.UseHandler(r)
|
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))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user