Skip to content

Commit

Permalink
Fix for #25. Provide a new configuration parameter ui-web-path.
Browse files Browse the repository at this point in the history
  • Loading branch information
oers committed Mar 6, 2016
1 parent 91a9d8a commit a7374f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,23 @@ func DefaultConfig() *Config {

type Config struct {
AuthFile string
WebPath string
}

var cfg = DefaultConfig()

func Configure() *Config {

//sanitize webpath
//add a leading slash
if cfg.WebPath != "" && !(cfg.WebPath[0] == '/') {
cfg.WebPath = "/" + cfg.WebPath
}

return cfg
}

func RegisterFlags() {
flag.StringVar(&cfg.AuthFile, "auth-file", envconf.FromEnvP("MH_AUTH_FILE", "").(string), "A username:bcryptpw mapping file")
flag.StringVar(&cfg.WebPath, "ui-web-path", envconf.FromEnvP("MH_UI_WEB_PATH", "").(string), "WebPath under which the ui is served (without leading or trailing slahes), e.g. 'mailhog'. Value defaults to ''")
}
1 change: 1 addition & 0 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ You can configure MailHog using command line options or environment variables:
| MH_SMTP_BIND_ADDR | -smtp-bind-addr | 0.0.0.0:1025 | Interface and port for SMTP server to bind to
| MH_STORAGE | -storage | memory | Set message storage: memory / mongodb
| MH_OUTGOING_SMTP | -outgoing-smtp | | JSON file defining outgoing SMTP servers
| MH_UI_WEB_PATH | -ui-web-path | | WebPath under which the ui is served (without leading or trailing slahes), e.g. 'mailhog'. Value defaults to ''

#### Note on HTTP bind addresses

Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ func configure() {
apiconf = cfgapi.Configure()
uiconf = cfgui.Configure()
comconf = cfgcom.Configure()

apiconf.WebPath = comconf.WebPath
uiconf.WebPath = comconf.WebPath
}

func main() {
Expand Down

0 comments on commit a7374f9

Please sign in to comment.