config

package
v0.0.0-...-a203ad5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfig

func GetConfig[T any](key string) (T, error)

Types

type Configuration

type Configuration struct {
	GinMode  string         `mapstructure:"gin_mode" validate:"required,oneof=debug release test"`
	AppEnv   string         `mapstructure:"app_env" validate:"required"`
	AppName  string         `mapstructure:"app_name" validate:"required"`
	Server   ServerConfig   `mapstructure:"server" validate:"required"`
	Database DatabaseConfig `mapstructure:"database" validate:"required"`
	Cors     CorsConfig     `mapstructure:"cors" validate:"required"`
	Crypto   CryptoConfig   `mapstructure:"crypto" validate:"required"`
	Jwt      JwtConfig      `mapstructure:"jwt" validate:"required"`
	Slack    SlackConfig    `mapstructure:"slack" validate:"required"`
}

func LoadConfig

func LoadConfig() *Configuration

type CorsConfig

type CorsConfig struct {
	AllowedOrigins   []string `mapstructure:"allowed_origins" validate:"required"`
	AllowMethods     []string `mapstructure:"allow_methods" validate:"required"`
	AllowHeaders     []string `mapstructure:"allow_headers" validate:"required"`
	ExposeHeaders    []string `mapstructure:"expose_headers" validate:"required"`
	AllowCredentials bool     `mapstructure:"allow_credentials"`
	MaxAge           int64    `mapstructure:"max_age" validate:"gte=0"`
}

type CryptoConfig

type CryptoConfig struct {
	Salt int `mapstructure:"salt" validate:"required,numeric,gt=1,lte=15"`
}

type DatabaseConfig

type DatabaseConfig struct {
	Name     string `validate:"required"`
	User     string `validate:"required"`
	Password string `validate:"required"`
	Host     string `validate:"required,hostname"`
	Port     int    `validate:"required,gt=0,lte=65535"`
	Schema   string
}

type JwtConfig

type JwtConfig struct {
	Secret     string `mapstructure:"secret" validate:"required"`
	Expiration string `mapstructure:"expiration" validate:"required"`
}

type ServerConfig

type ServerConfig struct {
	Host string `mapstructure:"host"`
	Port string `mapstructure:"port" validate:"required,numeric,gt=0,lte=65535"`
}

type SlackConfig

type SlackConfig struct {
	AccessToken string `mapstructure:"access_token" validate:"required"`
	Channel     string `mapstructure:"channel" validate:"required"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL