Added login, some auth methods and a couple routes with no implementation
This commit is contained in:
parent
f76aa74179
commit
f1cae0d660
79 changed files with 8971 additions and 10 deletions
|
@ -14,12 +14,17 @@ const (
|
|||
type Config struct {
|
||||
DatabasePath *string `yaml:"database_path"`
|
||||
Port *int `yaml:"port"`
|
||||
Secret *string `yaml:"secret"`
|
||||
}
|
||||
|
||||
func (c *Config) SetDefaults() {
|
||||
if c.Port == nil {
|
||||
c.Port = NewInt(DefaultPort)
|
||||
}
|
||||
|
||||
if c.Secret == nil {
|
||||
c.Secret = NewString(NewUUID())
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Config) IsValid() error {
|
||||
|
@ -31,6 +36,10 @@ func (c *Config) IsValid() error {
|
|||
return fmt.Errorf("port cannot be empty")
|
||||
}
|
||||
|
||||
if c.Secret == nil || *c.Secret == "" {
|
||||
return fmt.Errorf("secret cannot be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -45,5 +54,7 @@ func ReadConfig(path string) (*Config, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
config.SetDefaults()
|
||||
|
||||
return &config, nil
|
||||
}
|
||||
|
|
|
@ -7,6 +7,6 @@ import (
|
|||
func NewString(s string) *string { return &s }
|
||||
func NewInt(i int) *int { return &i }
|
||||
|
||||
func NewID() string {
|
||||
func NewUUID() string {
|
||||
return uuid.New().String()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue