32 lines
581 B
Go
32 lines
581 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type Config struct {
|
|
Server struct {
|
|
Port int `yaml:"port"`
|
|
TLS struct {
|
|
Enabled bool `yaml:"enabled"`
|
|
CertFile string `yaml:"cert_file"`
|
|
KeyFile string `yaml:"key_file"`
|
|
} `yaml:"tls"`
|
|
} `yaml:"server"`
|
|
Metrics struct {
|
|
Enabled bool `yaml:"enabled"`
|
|
Port int `yaml:"port"`
|
|
} `yaml:"metrics"`
|
|
}
|
|
|
|
func Load(filename string) (*Config, error) {
|
|
data, err := os.ReadFile(filename)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var config Config
|
|
err = yaml.Unmarshal(data, &config)
|
|
return &config, err
|
|
} |