config

package
v0.6.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig()

LoadConfig config file from given path

Types

type Config

type Config struct {
	ProjectName string         `json:"project_name"`
	Server      ServerConfig   `json:"server"`
	Database    DatabaseConfig `json:"database"`

	SecretsDuration int64   `json:"secrets_duration"`
	SecretsTokens   Secrets `json:"secrets_tokens"`
}

Config type represents the application settings

func Get

func Get() *Config

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

func (*Config) GetSecrets added in v0.6.0

func (c *Config) GetSecrets() (keys []string)

GetSecrets returns a list of tokens

type DatabaseConfig

type DatabaseConfig struct {
	Host            string        `json:"host"`
	Port            int           `json:"port"`
	User            string        `json:"user"`
	Password        string        `json:"password"`
	Name            string        `json:"dbname"`
	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 Secrets added in v0.6.0

type Secrets struct {
	User        string `json:"user"`
	Admin       string `json:"admin"`
	Integration string `json:"integration"`
}

Secrets models the data for the token configuration

type ServerConfig

type ServerConfig struct {
	Version                  string        `json:"version"`
	Port                     string        `json:"port"`
	PprofPort                string        `json:"pprof_port"`
	Mode                     string        `json:"mode"`
	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"`
	OpenSessionsPerUser      int64         `json:"open_sessions_per_user"`
	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

Jump to

Keyboard shortcuts

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