config

package
v0.0.0-...-11987fe Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug     bool   `env:"DEBUG"`
	AppDomain string `env:"APP_DOMAIN"`

	ServerHost         string `env:"SERVER_HOST"`
	ServerPort         int    `env:"SERVER_PORT"`
	ServerReadTimeout  int    `env:"SERVER_READ_TIMEOUT"`
	ServerWriteTimeout int    `env:"SERVER_WRITE_TIMEOUT"`

	ServerAllowOrigins []string `env:"SERVER_ALLOW_ORIGINS"`
	ServerAllowHeaders []string `env:"SERVER_ALLOW_HEADERS"`
	ServerAllowMethods []string `env:"SERVER_ALLOW_METHODS"`
}

Config represents the config of application.

func Load

func Load(opts *LoadOptions) (*Config, error)

Load will loads all variables from .env file & .env.{stage} file and the custom parameter store's variables to env process. After that, It will parse to a Config.

Stage must be expose to env process if application not runs in the local.

func (*Config) Validate

func (c *Config) Validate() error

Validate the config.

type LoadOptions

type LoadOptions struct {
	Stage         string
	AppName       string
	CustomHandler ParameterStoreHandler
}

LoadOptions is options for function load.

func (*LoadOptions) Validate

func (o *LoadOptions) Validate() error

type ParameterStoreHandler

type ParameterStoreHandler func(stage, appName string) error

ParameterStoreHandler is used to get parameter from another service and must be expose all parameters to the env.

Jump to

Keyboard shortcuts

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