1234567891011121314151617181920212223242526272829 |
- package config
- import (
- "fmt"
- "time"
- )
- type Configuration struct {
- Timeout int `yaml:"timeout"`
- Issuer string `yaml:"issuer"`
- Database Databases `yaml:"database"`
- }
- func (c Configuration) Invalidate() error {
- if c.Timeout < 1 {
- c.Timeout = 30
- }
- if c.Issuer == "" {
- return fmt.Errorf("`issuer` must not be an empty string")
- }
- return Invalidate(c)
- }
- func (c Configuration) TimeoutDuration() time.Duration {
- return time.Duration(c.Timeout) * time.Second
- }
|