1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-12-02 20:22:52 +00:00

default timeout

This commit is contained in:
Laura
2025-10-25 15:32:10 +02:00
parent 61f0d00bfa
commit 9fa1c29365
2 changed files with 6 additions and 7 deletions

5
env.go
View File

@@ -126,6 +126,11 @@ func (e *Environment) Init() error {
e.Settings.Transformation = "middle-out" e.Settings.Transformation = "middle-out"
} }
// default timeout
if env.Settings.Timeout <= 0 {
env.Settings.Timeout = 300
}
// create user lookup map // create user lookup map
e.Authentication.lookup = make(map[string]*EnvUser) e.Authentication.lookup = make(map[string]*EnvUser)

View File

@@ -14,19 +14,13 @@ func init() {
} }
func OpenRouterClient() *openrouter.Client { func OpenRouterClient() *openrouter.Client {
timeout := env.Settings.Timeout
if timeout <= 0 {
timeout = 1
}
cc := openrouter.DefaultConfig(env.Tokens.OpenRouter) cc := openrouter.DefaultConfig(env.Tokens.OpenRouter)
cc.XTitle = "Whiskr" cc.XTitle = "Whiskr"
cc.HttpReferer = "https://github.com/coalaura/whiskr" cc.HttpReferer = "https://github.com/coalaura/whiskr"
cc.HTTPClient = &http.Client{ cc.HTTPClient = &http.Client{
Timeout: time.Duration(timeout) * time.Second, Timeout: time.Duration(env.Settings.Timeout) * time.Second,
} }
return openrouter.NewClientWithConfig(*cc) return openrouter.NewClientWithConfig(*cc)