mirror of
https://github.com/gomods/athens
synced 2026-02-03 14:20:31 +00:00
* use sys env ATHENS_PORT instead of PORT * add default port * validate is not needed since we default a port now. add test for default port
26 lines
1.0 KiB
Go
26 lines
1.0 KiB
Go
package config
|
|
|
|
// ProxyConfig specifies the properties required to run the proxy
|
|
type ProxyConfig struct {
|
|
StorageType string `validate:"required" envconfig:"ATHENS_STORAGE_TYPE"`
|
|
GlobalEndpoint string `envconfig:"ATHENS_GLOBAL_ENDPOINT"` // This feature is not yet implemented
|
|
Port string `envconfig:"ATHENS_PORT" default:":3000"`
|
|
BasicAuthUser string `envconfig:"BASIC_AUTH_USER"`
|
|
BasicAuthPass string `envconfig:"BASIC_AUTH_PASS"`
|
|
ForceSSL bool `envconfig:"PROXY_FORCE_SSL"`
|
|
ValidatorHook string `envconfig:"ATHENS_PROXY_VALIDATOR"`
|
|
PathPrefix string `envconfig:"ATHENS_PATH_PREFIX"`
|
|
NETRCPath string `envconfig:"ATHENS_NETRC_PATH"`
|
|
GithubToken string `envconfig:"ATHENS_GITHUB_TOKEN"`
|
|
HGRCPath string `envconfig:"ATHENS_HGRC_PATH"`
|
|
}
|
|
|
|
// BasicAuth returns BasicAuthUser and BasicAuthPassword
|
|
// and ok if neither of them are empty
|
|
func (p *ProxyConfig) BasicAuth() (user, pass string, ok bool) {
|
|
user = p.BasicAuthUser
|
|
pass = p.BasicAuthPass
|
|
ok = user != "" && pass != ""
|
|
return user, pass, ok
|
|
}
|