config

package
v0.0.0-...-df959dd Latest Latest
Warning

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

Go to latest
Published: Mar 5, 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 {
	Hostname     string
	Port         uint16
	Password     string
	Database     int
	TestDatabase 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
	Mail     MailConfig
}

Config stores complete configuration

func GetConfig

func GetConfig() (Config, error)

GetConfig loads and returns configuration

type DatabaseConfig

type DatabaseConfig struct {
	Hostname     string
	Port         uint16
	User         string
	Password     string
	Database     string
	TestDatabase 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

Jump to

Keyboard shortcuts

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