Добавлен основные классы для сервиса авторизаци

This commit is contained in:
Ганеев Артем
2025-10-28 20:49:54 +03:00
parent def3552a67
commit 736b8031f8
26 changed files with 904 additions and 40 deletions

42
internal/config/config.go Normal file
View File

@@ -0,0 +1,42 @@
package config
import (
"os"
"gopkg.in/yaml.v3"
)
type Config struct {
Token TokenConfig `yaml:"token" json:"token"`
Server ServerConfig `yaml:"server" json:"server"`
DB DatabaseConfig `yaml:"db" json:"db"`
}
type ServerConfig struct {
Port string `yaml:"port" json:"port"`
}
type DatabaseConfig struct {
Username string `yaml:"username" json:"username"`
Host string `yaml:"host" json:"host"`
Port string `yaml:"port" json:"port"`
Sslmode string `yaml:"sslmode" json:"sslmode"`
DBname string `yaml:"dbname" json:"dbname"`
}
func LoadConfig(absolutePath string) (*Config, error) {
config := &Config{}
file, err := os.Open(absolutePath)
if err != nil {
return nil, err
}
defer file.Close()
decoder := yaml.NewDecoder(file)
if err := decoder.Decode(config); err != nil {
return nil, err
}
return config, nil
}