浏览代码

Validate imagefetcher config

DarthSim 1 月之前
父节点
当前提交
f12fe8414b
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      imagefetcher/config.go

+ 9 - 0
imagefetcher/config.go

@@ -1,6 +1,7 @@
 package imagefetcher
 
 import (
+	"errors"
 	"time"
 
 	"github.com/imgproxy/imgproxy/v3/config"
@@ -36,5 +37,13 @@ func (c *Config) LoadFromEnv() (*Config, error) {
 
 // Validate checks config for errors
 func (c *Config) Validate() error {
+	if len(c.UserAgent) == 0 {
+		return errors.New("user agent cannot be empty")
+	}
+
+	if c.DownloadTimeout <= 0 {
+		return errors.New("download timeout must be greater than 0")
+	}
+
 	return nil
 }