2015-05-27 17:08:44 +00:00
package config
import (
"flag"
"github.com/ian-kent/envconf"
)
func DefaultConfig ( ) * Config {
return & Config {
AuthFile : "" ,
}
}
type Config struct {
AuthFile string
2016-03-06 10:51:30 +00:00
WebPath string
2015-05-27 17:08:44 +00:00
}
var cfg = DefaultConfig ( )
func Configure ( ) * Config {
2016-03-06 10:51:30 +00:00
//sanitize webpath
//add a leading slash
if cfg . WebPath != "" && ! ( cfg . WebPath [ 0 ] == '/' ) {
cfg . WebPath = "/" + cfg . WebPath
}
2015-05-27 17:08:44 +00:00
return cfg
}
func RegisterFlags ( ) {
flag . StringVar ( & cfg . AuthFile , "auth-file" , envconf . FromEnvP ( "MH_AUTH_FILE" , "" ) . ( string ) , "A username:bcryptpw mapping file" )
2016-03-13 17:58:18 +00:00
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 slashes), e.g. 'mailhog'. Value defaults to ''" )
2015-05-27 17:08:44 +00:00
}