@@ -9,56 +9,58 @@ import (
99)
1010
1111type config struct {
12- Addr string
13- PublicURL string
14- SlackClientID string
15- SlackClientSecret string
16- SlackSigningSecret string
17- OAuthStateSecret string
18- SlackAPIBaseURL string
19- SlackBotScopes []string
20- PresetID string
21- BackendBaseURL string
22- BackendInternalToken string
23- SpritzBaseURL string
24- SpritzServiceToken string
25- PrincipalID string
26- HTTPTimeout time.Duration
27- DedupeTTL time.Duration
28- ProcessingTimeout time.Duration
29- SessionRetryInterval time.Duration
30- StatusMessageDelay time.Duration
31- RecoveryTimeout time.Duration
32- PromptRetryInitial time.Duration
33- PromptRetryMax time.Duration
34- PromptRetryTimeout time.Duration
12+ Addr string
13+ PublicURL string
14+ SlackClientID string
15+ SlackClientSecret string
16+ SlackSigningSecret string
17+ OAuthStateSecret string
18+ SlackAPIBaseURL string
19+ SlackBotScopes []string
20+ PresetID string
21+ BackendBaseURL string
22+ BackendFastAPIBaseURL string
23+ BackendInternalToken string
24+ SpritzBaseURL string
25+ SpritzServiceToken string
26+ PrincipalID string
27+ HTTPTimeout time.Duration
28+ DedupeTTL time.Duration
29+ ProcessingTimeout time.Duration
30+ SessionRetryInterval time.Duration
31+ StatusMessageDelay time.Duration
32+ RecoveryTimeout time.Duration
33+ PromptRetryInitial time.Duration
34+ PromptRetryMax time.Duration
35+ PromptRetryTimeout time.Duration
3536}
3637
3738func loadConfig () (config , error ) {
3839 cfg := config {
39- Addr : envOrDefault ("SPRITZ_SLACK_GATEWAY_ADDR" , ":8080" ),
40- PublicURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_GATEWAY_PUBLIC_URL" )), "/" ),
41- SlackClientID : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_CLIENT_ID" )),
42- SlackClientSecret : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_CLIENT_SECRET" )),
43- SlackSigningSecret : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_SIGNING_SECRET" )),
44- OAuthStateSecret : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_OAUTH_STATE_SECRET" )),
45- SlackAPIBaseURL : strings .TrimRight (envOrDefault ("SPRITZ_SLACK_API_BASE_URL" , "https://slack.com/api" ), "/" ),
46- SlackBotScopes : splitCSV (envOrDefault ("SPRITZ_SLACK_BOT_SCOPES" , "app_mentions:read,channels:history,chat:write,im:history,mpim:history" )),
47- PresetID : strings .TrimSpace (envOrDefault ("SPRITZ_SLACK_PRESET_ID" , defaultSlackPresetID )),
48- BackendBaseURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_BACKEND_BASE_URL" )), "/" ),
49- BackendInternalToken : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_BACKEND_INTERNAL_TOKEN" )),
50- SpritzBaseURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_SPRITZ_BASE_URL" )), "/" ),
51- SpritzServiceToken : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_SPRITZ_SERVICE_TOKEN" )),
52- PrincipalID : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_PRINCIPAL_ID" )),
53- HTTPTimeout : parseDurationEnv ("SPRITZ_SLACK_HTTP_TIMEOUT" , 15 * time .Second ),
54- DedupeTTL : parseDurationEnv ("SPRITZ_SLACK_DEDUPE_TTL" , 10 * time .Minute ),
55- ProcessingTimeout : parseDurationEnv ("SPRITZ_SLACK_PROCESSING_TIMEOUT" , 120 * time .Second ),
56- SessionRetryInterval : parseDurationEnv ("SPRITZ_SLACK_SESSION_RETRY_INTERVAL" , time .Second ),
57- StatusMessageDelay : parseDurationEnv ("SPRITZ_SLACK_STATUS_MESSAGE_DELAY" , 5 * time .Second ),
58- RecoveryTimeout : parseDurationEnv ("SPRITZ_SLACK_RECOVERY_TIMEOUT" , 120 * time .Second ),
59- PromptRetryInitial : parseDurationEnv ("SPRITZ_SLACK_PROMPT_RETRY_INITIAL" , 250 * time .Millisecond ),
60- PromptRetryMax : parseDurationEnv ("SPRITZ_SLACK_PROMPT_RETRY_MAX" , 2 * time .Second ),
61- PromptRetryTimeout : parseDurationEnv ("SPRITZ_SLACK_PROMPT_RETRY_TIMEOUT" , 8 * time .Second ),
40+ Addr : envOrDefault ("SPRITZ_SLACK_GATEWAY_ADDR" , ":8080" ),
41+ PublicURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_GATEWAY_PUBLIC_URL" )), "/" ),
42+ SlackClientID : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_CLIENT_ID" )),
43+ SlackClientSecret : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_CLIENT_SECRET" )),
44+ SlackSigningSecret : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_SIGNING_SECRET" )),
45+ OAuthStateSecret : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_OAUTH_STATE_SECRET" )),
46+ SlackAPIBaseURL : strings .TrimRight (envOrDefault ("SPRITZ_SLACK_API_BASE_URL" , "https://slack.com/api" ), "/" ),
47+ SlackBotScopes : splitCSV (envOrDefault ("SPRITZ_SLACK_BOT_SCOPES" , "app_mentions:read,channels:history,chat:write,im:history,mpim:history" )),
48+ PresetID : strings .TrimSpace (envOrDefault ("SPRITZ_SLACK_PRESET_ID" , defaultSlackPresetID )),
49+ BackendBaseURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_BACKEND_BASE_URL" )), "/" ),
50+ BackendFastAPIBaseURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_BACKEND_FASTAPI_BASE_URL" )), "/" ),
51+ BackendInternalToken : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_BACKEND_INTERNAL_TOKEN" )),
52+ SpritzBaseURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_SPRITZ_BASE_URL" )), "/" ),
53+ SpritzServiceToken : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_SPRITZ_SERVICE_TOKEN" )),
54+ PrincipalID : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_PRINCIPAL_ID" )),
55+ HTTPTimeout : parseDurationEnv ("SPRITZ_SLACK_HTTP_TIMEOUT" , 15 * time .Second ),
56+ DedupeTTL : parseDurationEnv ("SPRITZ_SLACK_DEDUPE_TTL" , 10 * time .Minute ),
57+ ProcessingTimeout : parseDurationEnv ("SPRITZ_SLACK_PROCESSING_TIMEOUT" , 120 * time .Second ),
58+ SessionRetryInterval : parseDurationEnv ("SPRITZ_SLACK_SESSION_RETRY_INTERVAL" , time .Second ),
59+ StatusMessageDelay : parseDurationEnv ("SPRITZ_SLACK_STATUS_MESSAGE_DELAY" , 5 * time .Second ),
60+ RecoveryTimeout : parseDurationEnv ("SPRITZ_SLACK_RECOVERY_TIMEOUT" , 120 * time .Second ),
61+ PromptRetryInitial : parseDurationEnv ("SPRITZ_SLACK_PROMPT_RETRY_INITIAL" , 250 * time .Millisecond ),
62+ PromptRetryMax : parseDurationEnv ("SPRITZ_SLACK_PROMPT_RETRY_MAX" , 2 * time .Second ),
63+ PromptRetryTimeout : parseDurationEnv ("SPRITZ_SLACK_PROMPT_RETRY_TIMEOUT" , 8 * time .Second ),
6264 }
6365
6466 if cfg .PublicURL == "" {
@@ -86,6 +88,9 @@ func loadConfig() (config, error) {
8688 if cfg .BackendBaseURL == "" {
8789 return config {}, fmt .Errorf ("SPRITZ_SLACK_BACKEND_BASE_URL is required" )
8890 }
91+ if cfg .BackendFastAPIBaseURL == "" {
92+ cfg .BackendFastAPIBaseURL = cfg .BackendBaseURL
93+ }
8994 if cfg .BackendInternalToken == "" {
9095 return config {}, fmt .Errorf ("SPRITZ_SLACK_BACKEND_INTERNAL_TOKEN is required" )
9196 }
0 commit comments