config.go 953 B

123456789101112131415161718192021222324252627282930313233
  1. package webhook
  2. import "time"
  3. // Config represents the configuration for a webhook client
  4. type Config struct {
  5. // BaseURL is the base URL for the webhook endpoint
  6. BaseURL string `json:"base_url" validate:"required,url"`
  7. // Domain identifies the source domain sending webhooks
  8. Domain string `json:"domain" validate:"required"`
  9. // SecretKey is used to sign webhook payloads
  10. SecretKey string `json:"secret_key" validate:"required"`
  11. // Timeout is the HTTP client timeout (default: 10s)
  12. Timeout time.Duration `json:"timeout"`
  13. // MaxRetries is the maximum number of retry attempts (default: 3)
  14. MaxRetries int `json:"max_retries"`
  15. // RetryBackoff is the duration to wait between retries (default: 1s)
  16. RetryBackoff time.Duration `json:"retry_backoff"`
  17. }
  18. // DefaultConfig returns a Config with default values
  19. func DefaultConfig() Config {
  20. return Config{
  21. Timeout: 10 * time.Second,
  22. MaxRetries: 3,
  23. RetryBackoff: time.Second,
  24. }
  25. }