diff --git a/env.go b/env.go index 22a6fa1..1029a7c 100644 --- a/env.go +++ b/env.go @@ -126,6 +126,11 @@ func (e *Environment) Init() error { e.Settings.Transformation = "middle-out" } + // default timeout + if env.Settings.Timeout <= 0 { + env.Settings.Timeout = 300 + } + // create user lookup map e.Authentication.lookup = make(map[string]*EnvUser) diff --git a/openrouter.go b/openrouter.go index cb14d71..f9dce2d 100644 --- a/openrouter.go +++ b/openrouter.go @@ -14,19 +14,13 @@ func init() { } func OpenRouterClient() *openrouter.Client { - timeout := env.Settings.Timeout - - if timeout <= 0 { - timeout = 1 - } - cc := openrouter.DefaultConfig(env.Tokens.OpenRouter) cc.XTitle = "Whiskr" cc.HttpReferer = "https://github.com/coalaura/whiskr" cc.HTTPClient = &http.Client{ - Timeout: time.Duration(timeout) * time.Second, + Timeout: time.Duration(env.Settings.Timeout) * time.Second, } return openrouter.NewClientWithConfig(*cc)