micw/server/config/config.go
2024-11-13 22:10:13 +01:00

47 lines
1.3 KiB
Go

package config
import (
commonCfg "git.mic.pp.ua/anderson/nettools/config"
"github.com/matchsystems/werr"
"gopkg.in/yaml.v3"
"os"
)
type Config struct {
Addr string `yaml:"addr"`
DbConfig any `yaml:"db_config"`
TlsCfg *commonCfg.FileTLS `yaml:"tls_cfg"`
HttpPort int `yaml:"http_port"`
HttpsPort int `yaml:"https_port"`
GrpcPort int `yaml:"grpc_port"`
}
type Processed struct {
// RewardersPublicKeys can reward people in the network with new crypto
RewardersPublicKeys []byte `yaml:"rewarders_public_keys"`
DbConnUrl string `yaml:"db_conn_url"`
Addr string `yaml:"addr"`
TlsCfg *commonCfg.TLS `yaml:"tls_cfg"`
HttpPort int `yaml:"http_port"`
HttpsPort int `yaml:"https_port"`
GrpcPort int `yaml:"grpc_port"`
}
func ReadConfigFile(filePath string) (*Config, error) {
fileData, err := os.ReadFile(filePath)
if err != nil {
return nil, werr.Wrapf(err, "failed to read config file %s", filePath)
}
config := &Config{}
if err := yaml.Unmarshal(fileData, config); err != nil {
return nil, werr.Wrapf(err, "failed to unmarshal config file %s", filePath)
}
return config, nil
}
func (c *Config) Process() (*Processed, error) {
return nil, nil
}