mirror of
https://github.com/yanislav-igonin/micrach
synced 2025-04-20 03:40:33 +03:00
feat: add geateway config
This commit is contained in:
parent
f7be64e1b4
commit
a942fa9448
@ -7,6 +7,11 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type GatewayConfig struct {
|
||||||
|
Url string
|
||||||
|
ApiKey string
|
||||||
|
}
|
||||||
|
|
||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
Env string
|
Env string
|
||||||
Port int
|
Port int
|
||||||
@ -15,6 +20,7 @@ type AppConfig struct {
|
|||||||
ThreadsMaxCount int
|
ThreadsMaxCount int
|
||||||
ThreadBumpLimit int
|
ThreadBumpLimit int
|
||||||
IsCaptchaActive bool
|
IsCaptchaActive bool
|
||||||
|
Gateway GatewayConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type DbConfig struct {
|
type DbConfig struct {
|
||||||
@ -46,6 +52,16 @@ func getValueOrDefaultString(value string, defaultValue string) string {
|
|||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getGatewayConfig() GatewayConfig {
|
||||||
|
url := os.Getenv("GATEWAY_URL")
|
||||||
|
apiKey := os.Getenv("GATEWAY_API_KEY")
|
||||||
|
|
||||||
|
return GatewayConfig{
|
||||||
|
Url: url,
|
||||||
|
ApiKey: apiKey,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getAppConfig() AppConfig {
|
func getAppConfig() AppConfig {
|
||||||
env := getValueOrDefaultString(os.Getenv("ENV"), "release")
|
env := getValueOrDefaultString(os.Getenv("ENV"), "release")
|
||||||
port := getValueOrDefaultInt(os.Getenv("PORT"), 3000)
|
port := getValueOrDefaultInt(os.Getenv("PORT"), 3000)
|
||||||
@ -54,6 +70,7 @@ func getAppConfig() AppConfig {
|
|||||||
threadsMaxCount := getValueOrDefaultInt(os.Getenv("THREADS_MAX_COUNT"), 50)
|
threadsMaxCount := getValueOrDefaultInt(os.Getenv("THREADS_MAX_COUNT"), 50)
|
||||||
threadBumpLimit := getValueOrDefaultInt(os.Getenv("THREAD_BUMP_LIMIT"), 500)
|
threadBumpLimit := getValueOrDefaultInt(os.Getenv("THREAD_BUMP_LIMIT"), 500)
|
||||||
isCaptchaActive := getValueOrDefaultBoolean(os.Getenv("IS_CAPTCHA_ACTIVE"), true)
|
isCaptchaActive := getValueOrDefaultBoolean(os.Getenv("IS_CAPTCHA_ACTIVE"), true)
|
||||||
|
gateway := getGatewayConfig()
|
||||||
|
|
||||||
return AppConfig{
|
return AppConfig{
|
||||||
Env: env,
|
Env: env,
|
||||||
@ -63,6 +80,7 @@ func getAppConfig() AppConfig {
|
|||||||
ThreadsMaxCount: threadsMaxCount,
|
ThreadsMaxCount: threadsMaxCount,
|
||||||
ThreadBumpLimit: threadBumpLimit,
|
ThreadBumpLimit: threadBumpLimit,
|
||||||
IsCaptchaActive: isCaptchaActive,
|
IsCaptchaActive: isCaptchaActive,
|
||||||
|
Gateway: gateway,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user