mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-14 10:17:26 +08:00
Merge pull request #57 from alexellis/port_cli
Introduce flag for TCP port
This commit is contained in:
commit
a85bb4a1d7
9
api.go
9
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))
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user