config

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup(configPath string) error

Setup initializes the configuration by loading environment variables and validating required settings.

Types

type Configuration

type Configuration struct {
	Server       ServerConfiguration
	Cors         CorsConfiguration
	Database     DatabaseConfiguration
	DatabaseSite DatabaseConfiguration // Site database connection
	Redis        RedisConfiguration
	GCS          GCSConfiguration
	RateLimiter  RateLimiterConfiguration
	Timezone     TimezoneConfiguration
}

Configuration holds all application configuration

var Config *Configuration

Config holds the global configuration instance

func GetConfig

func GetConfig() *Configuration

GetConfig returns the global configuration instance If no config is set, it will attempt to build from environment variables

type CorsConfiguration

type CorsConfiguration struct {
	Global bool
	Ips    string
}

CorsConfiguration holds CORS-related configuration

type DatabaseConfiguration

type DatabaseConfiguration struct {
	Driver           string
	Dbname           string
	Username         string
	Password         string
	Host             string
	Port             string
	Sslmode          bool
	Logmode          bool
	CloudSQLInstance string `mapstructure:"cloud_sql_instance"` // Cloud SQL instance connection name (format: project:region:instance)
}

DatabaseConfiguration holds database-related configuration

type GCSConfiguration

type GCSConfiguration struct {
	Enabled         bool
	BucketName      string
	CredentialsFile string // Path to service account JSON file (optional, uses ADC if not provided)
}

GCSConfiguration holds Google Cloud Storage-related configuration

type RateLimiterConfiguration added in v0.1.7

type RateLimiterConfiguration struct {
	Enabled   bool
	Requests  int    // Number of requests allowed per window
	Window    int    // Time window in seconds
	KeyBy     string // Key strategy: "ip" (default) or "user" (requires auth)
	SkipPaths string // Comma-separated list of paths to skip rate limiting (e.g., "/health,/metrics")
}

RateLimiterConfiguration holds rate limiter-related configuration

type RedisConfiguration

type RedisConfiguration struct {
	Enabled      bool
	Host         string
	Port         string
	Password     string
	DB           int
	ClusterMode  bool   // Enable cluster mode for Google Cloud Memorystore Redis Cluster
	ClusterNodes string // Comma-separated list of cluster node addresses (e.g., "10.0.0.1:6379,10.0.0.2:6379")
}

RedisConfiguration holds Redis-related configuration

type ServerConfiguration

type ServerConfiguration struct {
	Port               string
	Secret             string
	Mode               string
	AccessTokenExpiry  int // hours
	RefreshTokenExpiry int // days
	SessionExpiry      int // hours, default 24
	SessionCookieName  string
	SessionSecure      bool   // Set Secure flag for cookies (HTTPS only)
	SessionHttpOnly    bool   // Set HttpOnly flag for cookies (default true)
	SessionSameSite    string // SameSite cookie attribute: "strict", "lax", "none"
}

ServerConfiguration holds server-related configuration

type TimezoneConfiguration added in v0.1.7

type TimezoneConfiguration struct {
	Timezone string // IANA timezone identifier (e.g., "Asia/Jakarta", "UTC", "America/New_York")
}

TimezoneConfiguration holds timezone-related configuration

Jump to

Keyboard shortcuts

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