config

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config provides application configuration through environment variables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ServerHost is the host address the server will bind to.
	ServerHost string
	// ServerPort is the port number the server will listen on.
	ServerPort int

	// DBDriver is the database driver to use (e.g., "postgres", "mysql").
	DBDriver string
	// DBConnectionString is the connection string for the database.
	DBConnectionString string
	// DBMaxOpenConnections is the maximum number of open connections to the database.
	DBMaxOpenConnections int
	// DBMaxIdleConnections is the maximum number of idle connections in the database pool.
	DBMaxIdleConnections int
	// DBConnMaxLifetime is the maximum amount of time a connection may be reused.
	DBConnMaxLifetime time.Duration

	// LogLevel is the logging level (e.g., "debug", "info", "warn", "error").
	LogLevel string

	// AuthTokenExpiration is the duration after which an authentication token expires.
	AuthTokenExpiration time.Duration

	// RateLimitEnabled indicates whether rate limiting for authenticated endpoints is enabled.
	RateLimitEnabled bool
	// RateLimitRequestsPerSec is the number of requests allowed per second for authenticated endpoints.
	RateLimitRequestsPerSec float64
	// RateLimitBurst is the burst size for authenticated endpoints rate limiting.
	RateLimitBurst int

	// RateLimitTokenEnabled indicates whether rate limiting for the token endpoint is enabled.
	RateLimitTokenEnabled bool
	// RateLimitTokenRequestsPerSec is the number of requests allowed per second for the token endpoint.
	RateLimitTokenRequestsPerSec float64
	// RateLimitTokenBurst is the burst size for the token endpoint rate limiting.
	RateLimitTokenBurst int

	// CORSEnabled indicates whether CORS is enabled.
	CORSEnabled bool
	// CORSAllowOrigins is a comma-separated list of allowed origins for CORS.
	CORSAllowOrigins string

	// MetricsEnabled indicates whether metrics collection is enabled.
	MetricsEnabled bool
	// MetricsNamespace is the namespace for the application metrics.
	MetricsNamespace string
	// MetricsPort is the port number for the metrics server.
	MetricsPort int

	// KMSProvider is the KMS provider to use (e.g., "google", "aws", "azure").
	KMSProvider string
	// KMSKeyURI is the URI for the master key in the KMS.
	KMSKeyURI string

	// LockoutMaxAttempts is the maximum number of failed login attempts before a lockout.
	LockoutMaxAttempts int
	// LockoutDuration is the duration for which an account is locked out after maximum attempts.
	LockoutDuration time.Duration
}

Config holds all application configuration.

func Load

func Load() *Config

Load loads configuration from environment variables and .env file.

func (*Config) GetGinMode

func (c *Config) GetGinMode() string

GetGinMode returns the appropriate Gin mode based on log level.

Jump to

Keyboard shortcuts

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