environment

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPort is the default port Verbis should sit
	// on when none is defined.
	DefaultPort = 5000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Env

type Env struct {

	// Prod, production or dev.
	AppEnv string `json:"APP_ENV"`

	// If Verbis is in debug mode (true, false).
	AppDebug string `json:"APP_DEBUG"`

	// The port the server should listen to.
	AppPort string `json:"APP_PORT" binding:"required"`

	// The database port.
	DbDriver string `json:"DB_DRIVER" binding:"required"`

	// The database host (IP) for the store.
	DbHost string `json:"DB_HOST" binding:"required"`

	// The database port for the store.
	DbPort string `json:"DB_PORT" binding:"required"`

	// The database name.
	DbDatabase string `json:"DB_DATABASE" binding:"required"`

	// The database user name.
	DbUser string `json:"DB_USERNAME" binding:"required"`

	// The database port.
	DbPassword string `json:"DB_PASSWORD" binding:"required"`

	// The database port.
	DbSchema string `json:"DB_SCHEMA"`

	// The database port.
	MailDriver string `json:"MAIL_DRIVER"`

	// The mailing from address.
	MailFromAddress string `json:"MAIL_FROM_ADDRESS"`

	// The mailing from name.
	MailFromName string `json:"MAIL_FROM_NAME"`

	// The API key for Sparkpost.
	SparkpostAPIKey string `json:"SPARKPOST_API_KEY"`

	// The url for Sparkpost (could be EU).
	SparkpostURL string `json:"SPARKPOST_URL"`

	// The API key for MailGun.
	MailGunAPIKey string `json:"MAILGUN_API_KEY"`

	// The url for MailGun.
	MailGunURL string `json:"MAILGUN_URL"`

	// The domain for MailGun.
	MailGunDomain string `json:"MAILGUN_DOMAIN"`

	// The API key for SendGrid.
	SendGridAPIKey string `json:"SENDGRID_API_KEY"`
}

Env defines the environment variables set in the .env file. nolint

func Load

func Load() (*Env, error)

Load

Load populates environment, loads and validates the environment file.

Returns errors.INVALID if the env file failed to load.

func (*Env) IsDebug

func (e *Env) IsDebug() bool

IsDebug

If the application is set to debug.

func (*Env) IsProduction

func (e *Env) IsProduction() bool

IsProduction

If the application is set to production.

func (*Env) Port

func (e *Env) Port() int

Port

Returns the env port as an integer, if the strconv produced an error, the default port of 5000 will be used,

func (*Env) Set added in v0.0.3

func (e *Env) Set(key string, value interface{}) error

Set

Accepts a key, value pair and writes to the .env file when installing.

func (*Env) Validate

func (e *Env) Validate() validation.Errors

Validate

Validates the environment file for missing keys, if there are no validation errors, nil will be returned.

Jump to

Keyboard shortcuts

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