config

package
v0.0.0-...-3c357ad Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TemplateExt stores the extension used for the template files
	TemplateExt = ".gohtml"

	// StaticDir stores the name of the directory that will serve static files
	StaticDir = "static"

	// StaticPrefix stores the URL prefix used when serving static files
	StaticPrefix = "files"
)
View Source
const (
	// EnvLocal represents the local environment
	EnvLocal environment = "local"

	// EnvTest represents the test environment
	EnvTest environment = "test"

	// EnvDevelop represents the development environment
	EnvDevelop environment = "dev"

	// EnvStaging represents the staging environment
	EnvStaging environment = "staging"

	// EnvQA represents the qa environment
	EnvQA environment = "qa"

	// EnvProduction represents the production environment
	EnvProduction environment = "prod"
)

Variables

This section is empty.

Functions

func SwitchEnvironment

func SwitchEnvironment(env environment)

SwitchEnvironment sets the environment variable used to dictate which environment the application is currently running in. This must be called prior to loading the configuration in order for it to take effect.

Types

type AppConfig

type AppConfig struct {
	Name          string
	Environment   environment
	EncryptionKey string
	Timeout       time.Duration
	PasswordToken struct {
		Expiration time.Duration
		Length     int
	}
	EmailVerificationTokenExpiration time.Duration
}

AppConfig stores application configuration

type CacheConfig

type CacheConfig struct {
	Capacity   int
	Expiration struct {
		StaticFile time.Duration
		Page       time.Duration
	}
}

CacheConfig stores the cache configuration

type Config

type Config struct {
	HTTP     HTTPConfig
	App      AppConfig
	Cache    CacheConfig
	Database DatabaseConfig
	Tasks    TasksConfig
	Mail     MailConfig
}

Config stores complete configuration

func GetConfig

func GetConfig() (Config, error)

GetConfig loads and returns configuration

type DatabaseConfig

type DatabaseConfig struct {
	Driver         string
	Connection     string
	TestConnection string
}

DatabaseConfig stores the database configuration

type HTTPConfig

type HTTPConfig struct {
	Hostname     string
	Port         uint16
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	IdleTimeout  time.Duration
	TLS          struct {
		Enabled     bool
		Certificate string
		Key         string
	}
}

HTTPConfig stores HTTP configuration

type MailConfig

type MailConfig struct {
	Hostname    string
	Port        uint16
	User        string
	Password    string
	FromAddress string
}

MailConfig stores the mail configuration

type TasksConfig

type TasksConfig struct {
	Goroutines      int
	ReleaseAfter    time.Duration
	CleanupInterval time.Duration
}

TasksConfig stores the tasks configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳