47 lines
777 B
Go
47 lines
777 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type Config struct {
|
|
Server struct {
|
|
Port int `yaml:"port"`
|
|
Host string `yaml:"host"`
|
|
} `yaml:"server"`
|
|
|
|
Database struct {
|
|
Type string `yaml:"type"`
|
|
Path string `yaml:"path"`
|
|
} `yaml:"database"`
|
|
|
|
OAuth struct {
|
|
IssuerURL string `yaml:"issuer_url"`
|
|
ClientID string `yaml:"client_id"`
|
|
ClientSecret string `yaml:"client_secret"`
|
|
RedirectURL string `yaml:"redirect_url"`
|
|
} `yaml:"oauth"`
|
|
|
|
JWT struct {
|
|
SigningKey string `yaml:"signing_key"`
|
|
} `yaml:"jwt"`
|
|
}
|
|
|
|
var GlobalConfig Config
|
|
|
|
func Init() error {
|
|
configFile, err := os.ReadFile("config/config.yaml")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = yaml.Unmarshal(configFile, &GlobalConfig)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|