config

package
v0.0.0-...-d5dcd45 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config provides a singleton instance of the configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CORS

type CORS struct {
	AllowOrigins []string `envconfig:"CORS_ALLOW_ORIGINS" required:"true"`
}

CORS is the configuration for the CORS.

type Config

type Config struct {
	Environment EnvType `envconfig:"ENVIRONMENT" required:"true"`
	HTTP        HTTP
	Postgres    Postgres
	Logger      Logger
	Token       Token
	CORS        CORS
}

Config is the configuration for the application.

func Get

func Get() *Config

Get returns the singleton instance of the configuration.

func (*Config) IsDev

func (c *Config) IsDev() bool

IsDev check that environment is dev.

func (*Config) IsProd

func (c *Config) IsProd() bool

IsProd check that environment is prod.

func (*Config) IsTest

func (c *Config) IsTest() bool

IsTest check that environment is test.

type EnvType

type EnvType string

EnvType is the type of the environment.

type HTTP

type HTTP struct {
	Host           string        `envconfig:"HTTP_HOST"             required:"true"`
	Port           string        `envconfig:"HTTP_PORT"             required:"true"`
	MaxHeaderBytes int           `envconfig:"HTTP_MAX_HEADER_BYTES"                 default:"1"`
	ReadTimeout    time.Duration `envconfig:"HTTP_READ_TIMEOUT"                     default:"10s"`
	WriteTimeout   time.Duration `envconfig:"HTTP_WRITE_TIMEOUT"                    default:"10s"`
}

HTTP is the configuration for the HTTP server.

type Logger

type Logger struct {
	Level string `envconfig:"LOGGER_LEVEL" default:"info"`
}

Logger is the configuration for the logger.

type Postgres

type Postgres struct {
	Host     string `envconfig:"POSTGRES_HOST"     required:"true"`
	Port     string `envconfig:"POSTGRES_PORT"     required:"true"`
	DBName   string `envconfig:"POSTGRES_DBNAME"   required:"true"`
	User     string `envconfig:"POSTGRES_USER"     required:"true"`
	Password string `envconfig:"POSTGRES_PASSWORD" required:"true" json:"-"`
	SSLMode  string `envconfig:"POSTGRES_SSLMODE"                           default:"disable"`
}

Postgres is the configuration for the Postgres database.

type Token

type Token struct {
	SecretKey string        `envconfig:"TOKEN_SECRET_KEY" required:"true" json:"-"`
	Expired   time.Duration `envconfig:"TOKEN_EXPIRED"                             default:"15m"`
}

Token is the configuration for the token.

Jump to

Keyboard shortcuts

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