cfg

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Env = Config{}

Functions

func Load

func Load(path, profile string) error

Load loads config file located at given path according to given profile.

func LoadKeys

func LoadKeys(pvtPath, pubPath string) error

LoadKeys returns private key and public key loaded from pem files.

Types

type Config

type Config struct {
	DB     DB     `mapstructure:"db"`
	Token  Token  `mapstructure:"token"`
	Server Server `mapstructure:"server"`
}

Config contains all envs loaded from config file.

type DB

type DB struct {
	Type       string `mapstructure:"type"`
	User       string `mapstructure:"user"`
	Password   string `mapstructure:"password"`
	Proto      string `mapstructure:"protocol"`
	Addr       string `mapstructure:"address"`
	Schema     string `mapstructure:"schema"`
	Params     string `mapstructure:"params"`
	Migrations string `mapstructure:"migrations"`
}

DB contains database-related envs.

func (DB) DSN

func (db DB) DSN() string

DSN returns Data Source Name for db connection.

type Server

type Server struct {
	Host string `mapstructure:"host"`
	Port string `mapstructure:"port"`
}

Server contains server-related envs.

type Token

type Token struct {
	AccessDuration  int    `mapstructure:"accessDuration"`
	RefreshDuration int    `mapstructure:"refreshDuration"`
	PrivatePEM      string `mapstructure:"privatePem"`
	PublicPEM       string `mapstructure:"publicPem"`
	PrivateKey      crypto.PrivateKey
	PublicKey       crypto.PublicKey
	Issuer          string `mapstructure:"issuer"`
}

Token contains token-related envs.

Jump to

Keyboard shortcuts

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