Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Commit

Permalink
Add ability to set the listen address
Browse files Browse the repository at this point in the history
  • Loading branch information
hashworks committed Feb 20, 2018
1 parent df9e000 commit d80e40a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server.go
Expand Up @@ -23,6 +23,8 @@ var (
BUILD_COMMIT string = "unknown"
BUILD_DATE string = "unknown"
versionFlag bool
address string
port int
)

type server struct {
Expand All @@ -41,7 +43,9 @@ func (s server) internalServerError(c *gin.Context, err string) {
func main() {
flagSet := flag.NewFlagSet(os.Args[0], flag.ExitOnError)

flagSet.BoolVar(&versionFlag, "version", false, "")
flagSet.BoolVar(&versionFlag, "version", false, "Displays the version and license information.")
flagSet.StringVar(&address, "address", "127.0.0.1", "The address to listen on.")
flagSet.IntVar(&port, "port", 65431, "The port to listen on.")

flagSet.Parse(os.Args[1:])

Expand Down Expand Up @@ -153,5 +157,5 @@ func run() {
s.router.GET("/playsByTime/*usernames", s.playsByTimeHandler)
s.router.POST("/webhook", s.backendHandler)

s.router.Run(":65431")
s.router.Run(fmt.Sprintf("%s:%d", address, port))
}

0 comments on commit d80e40a

Please sign in to comment.