Add --bind flag to specify http server host

This commit is contained in:
Dan Sosedoff 2014-10-30 18:51:49 -05:00
parent 533ed06eb8
commit d325527aa6
2 changed files with 4 additions and 2 deletions

View File

@ -77,6 +77,7 @@ Application Options:
--pass= Password for user
--db= Database name (postgres)
--ssl= SSL option (disable)
--bind= HTTP server host (localhost)
--listen= HTTP server listen port (8080)
--auth-user= HTTP basic auth user
--auth-pass= HTTP basic auth password

View File

@ -22,6 +22,7 @@ var options struct {
Pass string `long:"pass" description:"Password for user"`
DbName string `long:"db" description:"Database name" default:"postgres"`
Ssl string `long:"ssl" description:"SSL option" default:"disable"`
HttpHost string `long:"bind" description:"HTTP server host" default:"localhost"`
HttpPort uint `long:"listen" description:"HTTP server listen port" default:"8080"`
AuthUser string `long:"auth-user" description:"HTTP basic auth user"`
AuthPass string `long:"auth-pass" description:"HTTP basic auth password"`
@ -120,7 +121,7 @@ func startServer() {
router.GET("/static/:type/:name", API_ServeAsset)
fmt.Println("Starting server...")
go router.Run(fmt.Sprintf(":%v", options.HttpPort))
go router.Run(fmt.Sprintf("%v:%v", options.HttpHost, options.HttpPort))
}
func handleSignals() {
@ -130,7 +131,7 @@ func handleSignals() {
}
func openPage() {
url := fmt.Sprintf("http://localhost:%v", options.HttpPort)
url := fmt.Sprintf("http://%v:%v", options.HttpHost, options.HttpPort)
fmt.Println("To view database open", url, "in browser")
if options.SkipOpen {