Skip to content

Commit

Permalink
feat: allow changing the listening port (#70)
Browse files Browse the repository at this point in the history
Allow changing the listening port via command line or configuration
file.

Signed-off-by: cubercsl <[email protected]>
  • Loading branch information
cubercsl authored Oct 11, 2023
1 parent c40e27c commit 482d1d0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
registerRoute(r)

srv := &http.Server{
Addr: ":8080",
Addr: viper.GetString("listen"),
Handler: r,
}

Expand Down Expand Up @@ -64,6 +64,7 @@ func runServer(srv *http.Server) {

func parseFlag() {
pflag.StringP("configFile", "c", "config.yaml", "config file")
pflag.StringP("listen", "l", ":8080", "listen address")
pflag.BoolP("version", "v", false, "version information")
pflag.Parse()
if err := viper.BindPFlags(pflag.CommandLine); err != nil {
Expand Down

0 comments on commit 482d1d0

Please sign in to comment.