mirror of
https://github.com/sosedoff/pgweb.git
synced 2024-12-14 19:21:46 +03:00
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
|
||||
--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
|
||||
|
5
main.go
5
main.go
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user