config

package
v0.0.0-...-64ba4e8 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 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 AIConfig

type AIConfig struct {
	Name string
	URL  string
	Key  string
}

AIConfig stores the ai configuration

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 {
	Choice     string
	Redis      CacheConfigRedis
	Otter      CacheConfigOtter
	Expiration struct {
		StaticFile time.Duration
		Page       time.Duration
	}
}

CacheConfig stores the cache configuration

type CacheConfigOtter

type CacheConfigOtter struct {
	Capacity int
}

CacheConfigOtter stores the cache configuration for the otter cache

type CacheConfigRedis

type CacheConfigRedis struct {
	Hostname     string
	Port         int
	Password     string
	Database     int
	TestDatabase int
}

CacheConfigRedis stores the cache configuration for the redis cache

type Config

type Config struct {
	HTTP     HTTPConfig
	App      AppConfig
	Cache    CacheConfig
	Database DatabaseConfig
	Tasks    TasksConfig
	Mail     MailConfig
	Stripe   StripeConfig
	AIs      []AIConfig
}

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 StripeConfig

type StripeConfig struct {
	URL           string
	Key           string
	WebhookSecret string
}

MailConfig stores the stripe 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