config

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnonymousAuthConfig added in v0.2.0

type AnonymousAuthConfig struct {
	Enabled bool   `mapstructure:"enabled"`
	Role    string `mapstructure:"role"`
}

type AuthConfig

type AuthConfig struct {
	Providers map[string]*OAuthProviderConfig `mapstructure:"providers"`
}

type Config

type Config struct {
	Server struct {
		Port                  int               `mapstructure:"port"`
		Host                  string            `mapstructure:"host"`
		RootURL               string            `mapstructure:"root_url"`
		CustomResponseHeaders map[string]string `mapstructure:"customer_response_headers"`
	} `mapstructure:"server"`

	Database struct {
		Host         string `mapstructure:"host"`
		Port         int    `mapstructure:"port"`
		User         string `mapstructure:"user"`
		Password     string `mapstructure:"password"`
		Name         string `mapstructure:"name"`
		SSLMode      string `mapstructure:"sslmode"`
		MaxConns     int    `mapstructure:"max_conns"`
		IdleConns    int    `mapstructure:"idle_conns"`
		ConnLifetime int    `mapstructure:"conn_lifetime"`
	} `mapstructure:"database"`

	Logging struct {
		Level  string `mapstructure:"level"`
		Format string `mapstructure:"format"`
	} `mapstructure:"logging"`

	Auth struct {
		Providers map[string]*OAuthProviderConfig `mapstructure:"providers"`
		Anonymous AnonymousAuthConfig             `mapstructure:"anonymous"`
	} `mapstructure:"auth"`
}

Config holds all configuration for the application

func Get

func Get() *Config

Get returns the current config, panics if config is not loaded

func Load

func Load(configPath string) (*Config, error)

Load initializes and loads the config

func (*Config) BuildDSN

func (c *Config) BuildDSN() string

BuildDSN builds a PostgreSQL connection string from config

type GroupMapConfig

type GroupMapConfig struct {
	GroupName string   `mapstructure:"group_name"`
	Roles     []string `mapstructure:"roles"`
}

type OAuthProviderConfig

type OAuthProviderConfig struct {
	Enabled      bool             `mapstructure:"enabled"`
	Type         string           `mapstructure:"type"`
	Name         string           `mapstructure:"name"`
	ClientID     string           `mapstructure:"client_id"`
	ClientSecret string           `mapstructure:"client_secret"`
	URL          string           `mapstructure:"url"`
	RedirectURL  string           `mapstructure:"redirect_url"`
	Scopes       []string         `mapstructure:"scopes"`
	AllowSignup  bool             `mapstructure:"allow_signup"`
	GroupMapping []GroupMapConfig `mapstructure:"group_mapping"`
}

Jump to

Keyboard shortcuts

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