cfg

package
v0.0.0-...-7e06a17 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(path string, config interface{}) error

Load reads the configuration from a yml file (at path) and from environment variables.

func LoadEnv

func LoadEnv(config interface{}) error

LoadEnv loads the environment variables into config struct.

func LoadYaml

func LoadYaml(path string, config interface{}) error

LoadYaml reads a yaml file at path in the config struct.

Types

type MaponConfig

type MaponConfig struct {
	URL       string     `yaml:"url" envconfig:"MAPON_URL"`
	Key       SafeString `yaml:"key" envconfig:"MAPON_KEY"`
	Endpoints struct {
		Unit  string `yaml:"unit" envconfig:"MAPON_ENDPOINTS_UNIT"`
		Route string `yaml:"route" envconfig:"MAPON_ENDPOINTS_ROUTE"`
	} `yaml:"endpoints"`
}

MaponConfig represents configuration for Mapon API connection.

type MongoConfig

type MongoConfig struct {
	Host        string     `yaml:"host" envconfig:"MONGO_HOST"`
	User        string     `yaml:"user" envconfig:"MONGO_USER"`
	Password    SafeString `yaml:"password" envconfig:"MONGO_PASSWORD"`
	Database    string     `yaml:"database" envconfig:"MONGO_DATABASE"`
	Collections struct {
		Users string `yaml:"users" envconfig:"MONGO_COLLECTIONS_USERS"`
	} `yaml:"collections"`
}

MongoConfig represents configuration for MongoDB connection.

type SafeString

type SafeString string

SafeString wraps string to implement fmt.Stringer and fmt.GoStringer funcs that return a constant string instead of the one stored. It is intended to avoid accidental value leak through fmt.

func (SafeString) GoString

func (SafeString) GoString() string

GoString returns a constant string representing the "Go-syntax" representation of a string.

func (SafeString) String

func (SafeString) String() string

String returns a constant string representing the "native" format of a string.

type SessionConfig

type SessionConfig struct {
	Cookie  string `yaml:"cookie" envconfig:"SESSION_COOKIE"`
	Expires int    `yaml:"expires" envconfig:"SESSION_EXPIRES"`
}

SessionConfig represents configuration for Session cookies.

Jump to

Keyboard shortcuts

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