73 lines
1.5 KiB
Go
73 lines
1.5 KiB
Go
package config
|
|
|
|
import (
|
|
"gopkg.in/yaml.v2"
|
|
"os"
|
|
)
|
|
|
|
type Config struct {
|
|
Db Database `yaml:"db"`
|
|
Storage Storage `yaml:"storage"`
|
|
PaymentService PaymentService `yaml:"paymentService"`
|
|
AuthService AuthService `yaml:"authService"`
|
|
StreamerService StreamerService `yaml:"streamerService"`
|
|
TtsHost string `yaml:"ttsHost"`
|
|
HOST string `yaml:"host"`
|
|
Cors CorsConfig `yaml:"cors"`
|
|
}
|
|
|
|
type Database struct {
|
|
Username string `yaml:"username"`
|
|
Password string `yaml:"password"`
|
|
Host string `yaml:"host"`
|
|
Port string `yaml:"port"`
|
|
DBName string `yaml:"dbname"`
|
|
}
|
|
|
|
type TtsService struct {
|
|
Host string `yaml:"host"`
|
|
}
|
|
|
|
type Storage struct {
|
|
Location string `yaml:"location"`
|
|
}
|
|
|
|
type PaymentService struct {
|
|
Host string `yaml:"host"`
|
|
Port string `yaml:"port"`
|
|
}
|
|
|
|
type AuthService struct {
|
|
Host string `yaml:"host"`
|
|
Port string `yaml:"port"`
|
|
}
|
|
|
|
type StreamerService struct {
|
|
Host string `yaml:"host"`
|
|
Port string `yaml:"port"`
|
|
}
|
|
|
|
type CorsConfig struct {
|
|
AllowedOrigins []string `yaml:"allow_origins"`
|
|
AllowedMethods []string `yaml:"allow_methods"`
|
|
AllowedHeaders []string `yaml:"allow_headers"`
|
|
AllowCredentials bool `yaml:"allow_credentials"`
|
|
ExposeHeaders []string `yaml:"expose_headers"`
|
|
MaxAge int `yaml:"max_age"`
|
|
}
|
|
|
|
func Init() *Config {
|
|
data, err := os.ReadFile("internal/config/config.yaml")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
var cfg Config
|
|
|
|
err = yaml.Unmarshal(data, &cfg)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return &cfg
|
|
}
|