mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-03 18:05:50 +02:00
NewDefaultConfig returns value, not pointer; Nested configs are defined as value
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"runtime"
|
||||
|
||||
"github.com/imgproxy/imgproxy/v3/config"
|
||||
"github.com/imgproxy/imgproxy/v3/ensure"
|
||||
)
|
||||
|
||||
// Config represents handler config
|
||||
@@ -14,8 +15,8 @@ type Config struct {
|
||||
}
|
||||
|
||||
// NewDefaultConfig creates a new configuration with defaults
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
func NewDefaultConfig() Config {
|
||||
return Config{
|
||||
RequestsQueueSize: 0,
|
||||
Workers: runtime.GOMAXPROCS(0) * 2,
|
||||
}
|
||||
@@ -23,9 +24,7 @@ func NewDefaultConfig() *Config {
|
||||
|
||||
// LoadConfigFromEnv loads config from environment variables
|
||||
func LoadConfigFromEnv(c *Config) (*Config, error) {
|
||||
if c == nil {
|
||||
c = NewDefaultConfig()
|
||||
}
|
||||
c = ensure.Ensure(c, NewDefaultConfig)
|
||||
|
||||
c.RequestsQueueSize = config.RequestsQueueSize
|
||||
c.Workers = config.Workers
|
||||
|
Reference in New Issue
Block a user