util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnv

func GetEnv(key string, defaultValue string) string

func GetEnvBool

func GetEnvBool(key string, defaultValue bool) bool

func GetEnvFloat

func GetEnvFloat[T constraints.Float](key string, defaultValue T) T

func GetEnvInt

func GetEnvInt[T constraints.Integer](key string, defaultValue T) T

func GetEnvSet

func GetEnvSet[T comparable](key string, defaultValue map[T]bool) map[T]bool

func GetEnvSlice

func GetEnvSlice[T comparable](key string, defaultValue []T) []T

Types

type CORS

type CORS struct {
	Enabled bool `mapstructure:"enabled"`
}

type Cache

type Cache struct {
	Enabled        bool     `mapstructure:"enabled"`
	TTL            int      `mapstructure:"ttl"`
	DisabledRoutes []string `mapstructure:"disabled_routes"`
	SizeMB         int      `mapstructure:"size_mb"`
}

type Config

type Config struct {
	ConfigFile               *ConfigFile
	DenyListTable            map[string]bool
	Rate                     *limiter.Rate
	CacheDisabledRoutesRegex []*regexp.Regexp
	BlockRoutesRegex         []*regexp.Regexp
	CacheStorage             *freecache.Cache
	CacheTTL                 time.Duration
	RequestLoggerConfig      *middleware.RequestLoggerConfig
	ProxyConfig              *middleware.ProxyConfig
}

func NewConfig

func NewConfig() *Config

type ConfigFile

type ConfigFile struct {
	Logger     Logger     `mapstructure:"logger"`
	RateLimit  RateLimit  `mapstructure:"rate_limit"`
	Cache      Cache      `mapstructure:"cache"`
	DenyList   DenyList   `mapstructure:"deny_list"`
	DenyRoutes DenyRoutes `mapstructure:"deny_routes"`
	Metrics    Metrics    `mapstructure:"metrics"`
	GC         GC         `mapstructure:"gc"`
	CORS       CORS       `mapstructure:"cors"`
	GZIP       GZIP       `mapstructure:"gzip"`
	Host       string     `mapstructure:"host"`
	TezosHost  string     `mapstructure:"tezos_host"`
}

type DenyList

type DenyList struct {
	Enabled bool     `mapstructure:"enabled"`
	Values  []string `mapstructure:"values"`
}

type DenyRoutes

type DenyRoutes struct {
	Enabled bool     `mapstructure:"enabled"`
	Values  []string `mapstructure:"values"`
}

type GC

type GC struct {
	Percent int `mapstructure:"percent"`
}

type GZIP

type GZIP struct {
	Enabled bool `mapstructure:"enabled"`
}

type Logger

type Logger struct {
	BunchSize           int `mapstructure:"bunch_size"`
	PoolIntervalSeconds int `mapstructure:"pool_interval_seconds"`
}

type Metrics

type Metrics struct {
	Host    string `mapstructure:"host"`
	Enabled bool   `mapstructure:"enabled"`
	Pprof   bool   `mapstructure:"pprof"`
}

type RateLimit

type RateLimit struct {
	Enabled bool    `mapstructure:"enabled"`
	Minutes float64 `mapstructure:"minutes"`
	Max     int     `mapstructure:"max"`
}

Jump to

Keyboard shortcuts

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