config

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultConfigFile is the default configuration file.
	DefaultConfigFile = "./config/config.yaml"
	// DefaultHost is the default host
	DefaultHost = "localhost"
	// DefaultPort is the default port to run the server on.
	DefaultPort = "8080"
	// DefaultPrivateKey is the default private key to use for signing tokens.
	DefaultPrivateKey = "./config/private.pem"
	// DefaultPublicKey is the default public key to use for verifying tokens.
	DefaultPublicKey = "./config/public.pem"
)
View Source
const (
	// DefaultDBDriver is the default database driver.
	DefaultDBDriver = "sqlite"
	// DefaultDBHost is the default database host.
	DefaultDBHost = ""
	// DefaultDBPort is the default database port.
	DefaultDBPort = ""
	// DefaultDBUser is the default database user.
	DefaultDBUser = ""
	// DefaultDBPassword is the default database password.
	DefaultDBPassword = ""
	// DefaultDBName is the default database name.
	DefaultDBName = "./config/sqlite.db"
)
View Source
const (
	// AvailableDatabaseDrivers is a list of available database drivers.
	AvailableDatabaseDrivers = "postgres,sqlite"
)

Variables

This section is empty.

Functions

func GetExecutablePath

func GetExecutablePath() (string, error)

GetExecutablePath returns the absolute path of the executable

func RelativePath

func RelativePath(basedir string, path *string)

RelativePath returns the absolute path of a relative path.

Types

type Config

type Config struct {
	Server   Server   `yaml:"server" json:"server"`
	Database Database `yaml:"database" json:"database"`
}

func GetConfig

func GetConfig() *Config

GetConfig returns the configuration struct.

func NewDefault

func NewDefault() *Config

NewDefault returns a new default configuration struct.

func (*Config) Load

func (cfg *Config) Load(file string) error

Load loads the configuration from a file.

type Database

type Database struct {
	Type     string `yaml:"type" json:"type" env:"DB_TYPE"`
	Host     string `yaml:"host,omitempty" json:"host,omitempty" env:"DB_HOST"`
	Port     string `yaml:"port,omitempty" json:"port,omitempty" env:"DB_PORT"`
	Username string `yaml:"user,omitempty" json:"user,omitempty" env:"DB_USER"`
	Password string `yaml:"pass,omitempty" json:"pass,omitempty" env:"DB_PASS"`
	Name     string `yaml:"name,omitempty" json:"name,omitempty" env:"DB_NAME"`
}

type Server

type Server struct {
	Host       string `yaml:"host,omitempty" json:"host,omitempty" env:"HOST"`
	Port       string `yaml:"port,omitempty" json:"port,omitempty" env:"PORT"`
	PrivateKey string `yaml:"private_key" json:"private_key" env:"PRIVATE_KEY"`
	PublicKey  string `yaml:"public_key" json:"public_key" env:"PUBLIC_KEY"`
}

Jump to

Keyboard shortcuts

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