config

package
v0.0.0-...-400441b Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Name string `mapstructure:"APP_NAME"`
	Env  string `mapstructure:"APP_ENV"`
}

App contains the configuration for the application.

type Config

type Config interface {
	// Load initializes the application and its dependencies configuration.
	Load() (*Container, error)
}

Config is an interface that defines the methods for the configuration loader.

func New

func New() (Config, error)

New initializes the configuration loader.

type Container

type Container struct {
	App      *App
	Http     *Http
	Database *Database
	Token    *Token
}

Container contains the configuration for the application and its dependencies.

type Database

type Database struct {
	Conn        string `mapstructure:"DB_CONNECTION"`
	Host        string `mapstructure:"DB_HOST"`
	Port        string `mapstructure:"DB_PORT"`
	Name        string `mapstructure:"DB_NAME"`
	Username    string `mapstructure:"DB_USERNAME"`
	Password    string `mapstructure:"DB_PASSWORD"`
	MaxLifeTime int    `mapstructure:"DB_MAX_LIFE_TIME"`
	MaxOpenConn int    `mapstructure:"DB_MAX_OPEN_CONNECTIONS"`
	MaxIdleConn int    `mapstructure:"DB_MAX_IDLE_CONNECTIONS"`
}

Database contains the configuration for the database.

type Http

type Http struct {
	Url            string `mapstructure:"HTTP_URL"`
	Port           string `mapstructure:"HTTP_PORT"`
	AllowedOrigins string `mapstructure:"HTTP_ALLOWED_ORIGINS"`
}

Http contains the configuration for the http server.

type Token

type Token struct {
	Type         string        `mapstructure:"TOKEN_TYPE"`
	SymmetricKey string        `mapstructure:"TOKEN_SYMMETRIC_KEY"`
	Duration     time.Duration `mapstructure:"TOKEN_DURATION"`
}

Token contains the configuration for the token.

type Viper

type Viper struct {
	*viper.Viper
}

Viper is a wrapper for configuration provider using viper library.

func (*Viper) Load

func (v *Viper) Load() (*Container, error)

Load initializes the application and its dependencies configuration.

Jump to

Keyboard shortcuts

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