Skip to content
This repository was archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #135 from wonko/feature/allow-host-to-bind-to
Browse files Browse the repository at this point in the history
Adds `host` option
  • Loading branch information
stefanprodan authored Jun 15, 2021
2 parents 8f36c6c + 7aaaa87 commit 10f88c4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cmd/mgob/mgob.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ func main() {
Usage: "HTTP port to listen on",
Value: 8090,
},
cli.StringFlag{
Name: "Host,h",
Usage: "HTTP host to listen on",
Value: "",
},
cli.BoolFlag{
Name: "JSONLog,j",
Usage: "logs in JSON format",
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *HttpServer) Start(version string) {

FileServer(r, "/storage", http.Dir(s.Config.StoragePath))

log.Error(http.ListenAndServe(fmt.Sprintf(":%v", s.Config.Port), r))
log.Error(http.ListenAndServe(fmt.Sprintf("%s:%v", s.Config.Host, s.Config.Port), r))
}

func FileServer(r chi.Router, path string, root http.FileSystem) {
Expand Down
1 change: 1 addition & 0 deletions pkg/config/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
type AppConfig struct {
LogLevel string `json:"log_level"`
JSONLog bool `json:"json_log"`
Host string `json:"host"`
Port int `json:"port"`
ConfigPath string `json:"config_path"`
StoragePath string `json:"storage_path"`
Expand Down

1 comment on commit 10f88c4

@NullP0interEx
Copy link

@NullP0interEx NullP0interEx commented on 10f88c4 Aug 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stefanprodan It looks like this commit is breaking the code ...

mgob flag redefined: h
panic: mgob flag redefined: h
goroutine 1 [running]:
flag.(*FlagSet).Var(0xc0000ae9c0, 0xb158e0, 0xc0000aac07, 0xa64b7c, 0x1, 0xa66837, 0x9)
/usr/local/go/src/flag/flag.go:851 +0x485
flag.(*FlagSet).BoolVar(...)
/usr/local/go/src/flag/flag.go:624
flag.(*FlagSet).Bool(0xc0000ae9c0, 0xa64b7c, 0x1, 0x0, 0xa66837, 0x9, 0x1)
/usr/local/go/src/flag/flag.go:637 +0x8a
github.com/urfave/cli.BoolFlag.ApplyWithError.func1(0xa64b7c, 0x1)
/go/pkg/mod/github.com/urfave/[email protected]/flag.go:352 +0xb1
github.com/urfave/cli.eachName(0xa64b76, 0x7, 0xc000093848)
/go/pkg/mod/github.com/urfave/[email protected]/flag.go:94 +0xe5
github.com/urfave/cli.BoolFlag.ApplyWithError(0xa64b76, 0x7, 0xa66837, 0x9, 0x0, 0x0, 0x0, 0x0, 0xc0000ae9c0, 0xa66db0, ...)
/go/pkg/mod/github.com/urfave/[email protected]/flag.go:347 +0x10c
github.com/urfave/cli.flagSet(0xa6212d, 0x4, 0xc000140000, 0xa, 0x10, 0xc000096190, 0x1, 0x1)
/go/pkg/mod/github.com/urfave/[email protected]/flag.go:80 +0x131
github.com/urfave/cli.(*App).Run(0xc00013e000, 0xc000096190, 0x1, 0x1, 0x0, 0x0)
/go/pkg/mod/github.com/urfave/[email protected]/app.go:187 +0x119
main.main()
/go/src/github.com/stefanprodan/mgob/cmd/mgob/mgob.go:89 +0x6b6

Please sign in to comment.