config.go 440 B

123456789101112131415161718192021222324252627
  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. }
  10. func (c Configuration) Invalidate() error {
  11. if c.Timeout < 1 {
  12. c.Timeout = 30
  13. }
  14. if c.Issuer == "" {
  15. return fmt.Errorf("`issuer` must not be an empty string")
  16. }
  17. return Invalidate(c)
  18. }
  19. func (c Configuration) TimeoutDuration() time.Duration {
  20. return time.Duration(c.Timeout) * time.Second
  21. }