First pass of authentication
This commit is contained in:
parent
c943864edc
commit
01c6e9de87
15 changed files with 311 additions and 42 deletions
26
config/config.go
Normal file
26
config/config.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Netflix/go-env"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
DataDir string `env:"DATA_DIR"`
|
||||
SiteDomain string `env:"SITE_DOMAIN"`
|
||||
LoginLocked bool `env:"LOGIN_LOCKED,default=false"`
|
||||
Env string `env:"ENV,default=prod"`
|
||||
}
|
||||
|
||||
func LoadConfig() (Config, error) {
|
||||
cfg := Config{}
|
||||
if _, err := env.UnmarshalFromEnviron(&cfg); err != nil {
|
||||
return Config{}, fmt.Errorf("failed to load config: %w", err)
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
func (c Config) IsProd() bool {
|
||||
return c.Env != "dev"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue