63 lines
1.2 KiB
Go
63 lines
1.2 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"`
|
|
}
|
|
|
|
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"`
|
|
}
|
|
|
|
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
|
|
}
|