Add --bind flag to specify http server host
This commit is contained in:
parent
533ed06eb8
commit
d325527aa6
@ -77,6 +77,7 @@ Application Options:
|
|||||||
--pass= Password for user
|
--pass= Password for user
|
||||||
--db= Database name (postgres)
|
--db= Database name (postgres)
|
||||||
--ssl= SSL option (disable)
|
--ssl= SSL option (disable)
|
||||||
|
--bind= HTTP server host (localhost)
|
||||||
--listen= HTTP server listen port (8080)
|
--listen= HTTP server listen port (8080)
|
||||||
--auth-user= HTTP basic auth user
|
--auth-user= HTTP basic auth user
|
||||||
--auth-pass= HTTP basic auth password
|
--auth-pass= HTTP basic auth password
|
||||||
|
5
main.go
5
main.go
@ -22,6 +22,7 @@ var options struct {
|
|||||||
Pass string `long:"pass" description:"Password for user"`
|
Pass string `long:"pass" description:"Password for user"`
|
||||||
DbName string `long:"db" description:"Database name" default:"postgres"`
|
DbName string `long:"db" description:"Database name" default:"postgres"`
|
||||||
Ssl string `long:"ssl" description:"SSL option" default:"disable"`
|
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"`
|
HttpPort uint `long:"listen" description:"HTTP server listen port" default:"8080"`
|
||||||
AuthUser string `long:"auth-user" description:"HTTP basic auth user"`
|
AuthUser string `long:"auth-user" description:"HTTP basic auth user"`
|
||||||
AuthPass string `long:"auth-pass" description:"HTTP basic auth password"`
|
AuthPass string `long:"auth-pass" description:"HTTP basic auth password"`
|
||||||
@ -120,7 +121,7 @@ func startServer() {
|
|||||||
router.GET("/static/:type/:name", API_ServeAsset)
|
router.GET("/static/:type/:name", API_ServeAsset)
|
||||||
|
|
||||||
fmt.Println("Starting server...")
|
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() {
|
func handleSignals() {
|
||||||
@ -130,7 +131,7 @@ func handleSignals() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func openPage() {
|
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")
|
fmt.Println("To view database open", url, "in browser")
|
||||||
|
|
||||||
if options.SkipOpen {
|
if options.SkipOpen {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user