config

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option[T OptionValueType] struct {
	Name         string
	Description  string
	IsAddedToCLI bool
	Value        T
}

func (*Option[T]) GetEnvName

func (o *Option[T]) GetEnvName() string

func (*Option[T]) GetFlagName

func (o *Option[T]) GetFlagName() string

func (*Option[T]) GetHeaderName

func (o *Option[T]) GetHeaderName() string

func (*Option[T]) MarkAsAddedToCLI

func (o *Option[T]) MarkAsAddedToCLI()

MarkAsAddedToCLI developed for avoiding forgetting adding config's fields to the cobra CLI commands

type OptionValueType

type OptionValueType interface {
	int | string | float64 | []string
}

type StartCommandConfig

type StartCommandConfig struct {
	LogLevel                  Option[string]   `default:"debug" description:"Verbosity level (panic, fatal, error, warn, info, debug, trace)"`
	LocalPort                 Option[int]      `default:"80" description:"Listening port for the proxy"`
	RemoteURI                 Option[string]   `default:"https://example.com:443" description:"URI of the remote resource"`
	ThrottleRateLimit         Option[float64]  `description:"How many requests can be send to the remote resource per second"`
	TransformRequestUrlSED    Option[string]   `description:"SED expression for request URL transformation"`
	AdditionalRequestHeaders  Option[[]string] `description:"Array of additional request headers in format Header: Value"`
	TransformRequestBodySED   Option[[]string] `description:"Pipeline of SED expressions for request body transformation"`
	TransformRequestBodyJQ    Option[[]string] `description:"Pipeline of JQ expressions for request body transformation"`
	AdditionalResponseHeaders Option[[]string] `description:"Array of additional response headers in format Header: Value"`
	TransformResponseBodySED  Option[[]string] `description:"Pipeline of SED expressions for response body transformation"`
	TransformResponseBodyJQ   Option[[]string] `description:"Pipeline of JQ expressions for response body transformation"`
}

func GetStartCommandConfig

func GetStartCommandConfig() *StartCommandConfig

func (*StartCommandConfig) GetLogLevelLogrus

func (c *StartCommandConfig) GetLogLevelLogrus() logrus.Level

func (*StartCommandConfig) GetStateHash

func (c *StartCommandConfig) GetStateHash() string

func (*StartCommandConfig) SetFromEnv

func (c *StartCommandConfig) SetFromEnv() error

func (*StartCommandConfig) SetFromHTTPRequestHeaders

func (c *StartCommandConfig) SetFromHTTPRequestHeaders(header http.Header, logger *logrus.Logger) error

TODO add availableInRuntime mapstructure flag and based on this flag throw the error if the user try to change cfg for this field through the http headers

func (*StartCommandConfig) Validate

func (c *StartCommandConfig) Validate() error

Jump to

Keyboard shortcuts

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