aboutsummaryrefslogblamecommitdiff
path: root/pkg/config/config.go
blob: 6a9d30cb63356bcf931947ea14354e0d11abd77a (plain) (tree)


























                                                   
package config

import (
	"os"

	"go.neonxp.ru/framework/pkg/db"
	"gopkg.in/yaml.v3"
)

type Config struct {
	Debug    bool              `yaml:"debug"`
	DB       *db.Config        `yaml:"db"`
	Listen   string            `yaml:"listen"`
	Host     string            `yaml:"host"`
	Admins   map[string]string `yaml:"admins"`
	Keypairs []string          `yaml:"keys"`
}

func New(file string) (*Config, error) {
	cfg := new(Config)
	fp, err := os.Open(file)
	if err != nil {
		return nil, err
	}

	return cfg, yaml.NewDecoder(fp).Decode(cfg)
}