config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const LoggerEncodingConsole string = "console"

LoggerEncodingConsole represents the encoding form that the log represents

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig()

LoadConfig config file from given path

Types

type Config

type Config struct {
	Meta          MetaConfig     `json:"meta"`
	Server        ServerConfig   `json:"server"`
	Logger        Logger         `json:"logger"`
	Mailer        MailerConfig   `json:"mailer"`
	Database      DatabaseConfig `json:"database"`
	UserAuthToken TokenConfig    `json:"user_auth_token"`
}

Config type represents the application settings

func Get

func Get() *Config

Get returns a pointer to a config struct which holds a valid config

type DatabaseConfig

type DatabaseConfig struct {
	Host            string        `json:"host"`
	Port            int           `json:"port"`
	User            string        `json:"user"`
	Password        string        `json:"password"`
	Dbname          string        `json:"dbname"`
	Driver          string        `json:"driver"`
	SSLMode         bool          `json:"sslmode"`
	MaxOpenConns    int           `json:"max_open_conns"`
	MaxIdleConns    int           `json:"max_idle_conns"`
	Timeout         int64         `json:"timeout"`
	ConnMaxLifetime time.Duration `json:"conn_max_life_time"`
	ConnMaxIdleTime time.Duration `json:"conn_max_idle_time"`
}

DatabaseConfig models postgres database configuration data

type Logger

type Logger struct {
	Development       bool   `json:"development"`
	DisableCaller     bool   `json:"disable_caller"`
	DisableStacktrace bool   `json:"disable_stacktrace"`
	Encoding          string `json:"encoding"`
	Level             string `json:"level"`
}

Logger models the data for the logs configuration

type MailerConfig

type MailerConfig struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Email    string `json:"email"`
	Username string `json:"username"`
	Password string `json:"password"`
	TLS      bool   `json:"tls"`
}

MailerConfig models the data for the mailer configuration

type MetaConfig

type MetaConfig struct {
	ProjectName string `json:"project_name"`
	ProjectURL  string `json:"project_url"`
}

MetaConfig models the meta configuration

type ServerConfig

type ServerConfig struct {
	Version                  string        `json:"version"`
	Port                     string        `json:"port"`
	PprofPort                string        `json:"pprof_port"`
	Mode                     string        `json:"mode"`
	JwtSecretKey             string        `json:"jwt_secret_key"`
	CookieName               string        `json:"cookie_name"`
	AccessLogDirectory       string        `json:"access_log_directory"`
	ErrorLogDirectory        string        `json:"error_log_directory"`
	PermissionBase           string        `json:"permission_base"`
	AccessControlAllowOrigin string        `json:"access_control_allow_origin"`
	SSL                      bool          `json:"ssl"`
	CSRF                     bool          `json:"srf"`
	Debug                    bool          `json:"debug"`
	StartHTTP                bool          `json:"start_http"`
	StartGRPC                bool          `json:"start_grpc"`
	CtxDefaultTimeout        time.Duration `json:"ctx_default_timeout"`
	ReadTimeout              time.Duration `json:"read_timeout"`
	WriteTimeout             time.Duration `json:"write_timeout"`
}

ServerConfig models a server's configuration data

func (*ServerConfig) IsModeDevelopment

func (sc *ServerConfig) IsModeDevelopment() bool

IsModeDevelopment returns if in development mode

func (*ServerConfig) IsModeProduction

func (sc *ServerConfig) IsModeProduction() bool

IsModeProduction returns if in production mode

type TokenConfig

type TokenConfig struct {
	SecretKey string `json:"secret_key"`
	Duration  int64  `json:"duration"`
}

TokenConfig models the data for the token configuration

Jump to

Keyboard shortcuts

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