env

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CORS

type CORS struct {
	AccessControlAllowHeaders  string `env:"ACCESS_CONTROL_ALLOW_HEADERS" env-default:""`
	AccessControlExposeHeaders string `env:"ACCESS_CONTROL_EXPOSE_HEADERS" env-default:""`
	AccessControlAllowMethods  string `env:"ACCESS_CONTROL_ALLOW_METHODS" env-default:""`
	AccessControlAllowOrigin   string `env:"ACCESS_CONTROL_ALLOW_ORIGIN" env-default:""`
}

type Centrifugo

type Centrifugo struct {
	ServerURL string `env:"SERVER_CENTRIFUGO_URL" env-default:"localhost:5000"`
	APIURL    string `env:"API_CENTRIFUGO_URL" env-default:"http://127.0.0.1:8000"`
	APIKey    string `env:"API_CENTRIFUGO_KEY" env-required:"true"`
}

type Config

type Config struct {
	AppName     string `env:"APP_NAME" env-required:"true"`
	AppURL      string `env:"APP_URL" env-default:"http://localhost"`
	Env         string `env:"ENV" env-default:"dev"`
	Debug       Debug
	Profiling   bool   `env:"PROFILING" env-default:"false"`
	DatabaseDSN string `env:"DATABASE_DSN" env-required:"true"`
	HTTPServer  HTTPServer
	Logger      Logger
	CORS        CORS
	JWT         JWT
	Mail        Mail
	Static      Static
	RabbitMQ    RabbitMQ
	Redis       Redis
	Centrifugo  Centrifugo
}

func GetConfigInstance

func GetConfigInstance() *Config

func MustLoadConfig

func MustLoadConfig() *Config

type Debug

type Debug struct {
	Debug        bool `env:"DEBUG" env-default:"false"`
	DebugRequest bool `env:"DEBUG_REQUEST" env-default:"false"`
	DebugBody    bool `env:"DEBUG_BODY" env-default:"false"`
	Profiling    bool `env:"PROFILING" env-default:"false"`
}

type HTTPServer

type HTTPServer struct {
	Address     string        `env:"HTTP_SERVER_ADDRESS" env-default:"localhost:8080" env-required:"true"`
	Timeout     time.Duration `env:"HTTP_SERVER_TIMEOUT" env-required:"true"`
	IdleTimeout time.Duration `env:"HTTP_SERVER_IDLE_TIMEOUT" env-required:"true"`
	TLS         TLS
}

type JWT

type JWT struct {
	PublicKey       string        `env:"JWT_PUBLIC_KEY" env-required:"true"`
	PrivateKey      string        `env:"JWT_PRIVATE_KEY" env-required:"true"`
	Algorithm       string        `env:"JWT_TOKEN_ALGORITHM" env-default:"HS256"`
	AccessLifeTime  time.Duration `env:"TOKEN_ACCESS_LIFE_TIME_SECONDS" env-default:"3600s"`
	RefreshLifeTime time.Duration `env:"TOKEN_REFRESH_LIFE_TIME_SECONDS" env-default:"7200s"`
	ConfirmLifeTime time.Duration `env:"TOKEN_CONFIRM_LIFE_TIME_SECONDS" env-default:"7200s"`
	SystemAPIKey    string        `env:"SYSTEM_API_KEY" env-required:"true"`
}

type Logger

type Logger struct {
	FilePath string `env:"LOGGER_FILE_PATH"`
}

type Mail

type Mail struct {
	Host        string `env:"MAIL_HOST" env-required:"true"`
	Port        int    `env:"MAIL_PORT" env-required:"true"`
	Username    string `env:"MAIL_USERNAME" env-required:"true"`
	Password    string `env:"MAIL_PASSWORD" env-required:"true"`
	AddressFrom string `env:"MAIL_FROM_ADDRESS" env-required:"true"`
}

type RabbitMQ

type RabbitMQ struct {
	Host     string `env:"RABBITMQ_HOST" env-required:"true"`
	Port     int    `env:"RABBITMQ_PORT" env-required:"true"`
	User     string `env:"RABBITMQ_USER" env-required:"true"`
	Password string `env:"RABBITMQ_PASSWORD" env-required:"true"`
	Vhost    string `env:"RABBITMQ_VHOST" env-required:"true"`
}

type Redis

type Redis struct {
	Host     string `env:"REDIS_HOST" env-default:"127.0.0.1"`
	Port     string `env:"REDIS_PORT" env-default:"6379"`
	Password string `env:"REDIS_PASSWORD" env-default:""`
	DB       int    `env:"REDIS_DB" env-default:"0"`
}

type Static

type Static struct {
	Enable    bool   `env:"HTTP_STATIC" env-default:"false"`
	Directory string `env:"HTTP_STATIC_DIR" env-default:"HTTP_STATIC_DIR"`
	URL       string `env:"HTTP_STATIC_URL" env-default:"HTTP_STATIC_URL"`
}

type TLS

type TLS struct {
	Cert string `env:"TLS_CERT" env-default:""`
	Key  string `env:"TLS_KEY" env-default:""`
}

func (*TLS) GetCertData

func (t *TLS) GetCertData() interface{}

func (*TLS) GetKeyData

func (t *TLS) GetKeyData() interface{}

func (*TLS) IsSet

func (t *TLS) IsSet() bool

Jump to

Keyboard shortcuts

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