config.go 479 B

1234567891011121314151617181920212223242526272829
  1. package config
  2. import (
  3. "fmt"
  4. "time"
  5. )
  6. type Configuration struct {
  7. Timeout int `yaml:"timeout"`
  8. Issuer string `yaml:"issuer"`
  9. Database Databases `yaml:"database"`
  10. }
  11. func (c Configuration) Invalidate() error {
  12. if c.Timeout < 1 {
  13. c.Timeout = 30
  14. }
  15. if c.Issuer == "" {
  16. return fmt.Errorf("`issuer` must not be an empty string")
  17. }
  18. return Invalidate(c)
  19. }
  20. func (c Configuration) TimeoutDuration() time.Duration {
  21. return time.Duration(c.Timeout) * time.Second
  22. }