config

package
v0.0.0-...-9b5353e Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 6 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 {
	AppName    string `env:"APP_NAME" envDefault:"boilerplate"`
	ServerPort int    `env:"PORT" envDefault:"8000"`
	Env        string `env:"ENV" envDefault:"env not set"`
	LogLevel   string `env:"LOG_LEVEL" envDefault:"debug"`
	LogOutput  string `env:"LOG_OUTPUT" envDefault:"console"`

	IdleTimeout time.Duration `env:"IDLE_TIMEOUT" envDefault:"5s"`
	// WriteTimeout maximum time the server will handle a request before timing out writes of the response.
	// It must be bigger than RequestTimeout
	WriteTimeout time.Duration `env:"WRITE_TIMEOUT" envDefault:"4s"`
	// RequestTimeout the timeout for the incoming request set on the request handler
	RequestTimeout    time.Duration `env:"REQUEST_TIMEOUT" envDefault:"2s"`
	ReadHeaderTimeout time.Duration `env:"READ_HEADER_TIMEOUT" envDefault:"1s"`

	// ShutdownTimeout the time the sever will wait server.Shutdown to return
	ShutdownTimeout time.Duration `env:"SHUTDOWN_TIMEOUT" envDefault:"6s"`
}

Config - environment variables are parsed to this struct

func Parse

func Parse() (Config, error)

Parse environment variables, returns (guess what?) an error if an error occurs

func (Config) Logger

func (c Config) Logger() zerolog.Logger

Logger returns a initialised zerolog.Logger

Jump to

Keyboard shortcuts

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