26 lines
532 B
Go
26 lines
532 B
Go
package main
|
|
|
|
import (
|
|
"io/ioutil"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type Config struct {
|
|
Password string `yaml:"password"`
|
|
CookieStoreKey string `yaml:"cookie_store_key"`
|
|
JWTSigningKey string `yaml:"jwt_signing_key"`
|
|
JWTExpireTime uint `yaml:"jwt_expire_time"`
|
|
}
|
|
|
|
// ReadFile reads the config file placed at the given path.
|
|
func ReadConfig(path string, config *Config) error {
|
|
cf, err := ioutil.ReadFile(path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := yaml.Unmarshal(cf, config); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|