feat: Add flags to set listening address/port
This commit is contained in:
parent
11046cb501
commit
98d22b9f72
1 changed files with 8 additions and 3 deletions
7
main.go
7
main.go
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
|
@ -17,10 +18,14 @@ import (
|
|||
|
||||
var (
|
||||
flagHelp bool
|
||||
listenAddress string
|
||||
listenPort string
|
||||
version string
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&listenAddress, "i", "", "IP address the HTTP server should bind to (all available addresses by default)")
|
||||
flag.StringVar(&listenPort, "p", "8080", "Port the HTTP server should listen on")
|
||||
flag.BoolVar(&flagHelp, "h", false, "Print help output")
|
||||
}
|
||||
|
||||
|
|
@ -94,5 +99,5 @@ func main() {
|
|||
|
||||
// Start webserver
|
||||
log.Println("Starting HTTP server...")
|
||||
log.Fatalln(http.ListenAndServe(":8080", nil))
|
||||
log.Fatalln(http.ListenAndServe(fmt.Sprintf("%s:%s", listenAddress, listenPort), nil))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue