config

package
v2.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogSourceConfigAllTrue = LogSourceConfig{
	LogConnectionStats: true,
	LogRequestHeaders:  true,
	LogRequest:         true,
	LogResponseHeaders: true,
	LogResponse:        true,
}

LogSourceConfigAllTrue is a LogSourceConfig with all fields set to true

Functions

This section is empty.

Types

type AppMode

type AppMode int

AppMode is an enum that represents different user-specified modes for the app

const (
	// ProxyRunMode is the default mode, which runs the proxy without any additional features
	ProxyRunMode AppMode = iota

	// CacheMode runs the proxy with the literal cache feature enabled
	CacheMode

	// APIAuditMode runs the proxy with the API audit feature enabled, which shows the real-time cost for each API call
	APIAuditMode
)

func (AppMode) String added in v2.4.0

func (a AppMode) String() string

type CacheEngine added in v2.4.0

type CacheEngine int

CacheEngine is an enum that represents different cache storage engines

const (
	// CacheEngineMemory is an in-memory cache engine
	CacheEngineMemory CacheEngine = iota

	// CacheEngineBolt is a file-based cache engine
	CacheEngineBolt
)

func (CacheEngine) String added in v2.4.0

func (c CacheEngine) String() string

type Config

type Config struct {
	AppMode       AppMode
	Cache         *cacheBehavior
	HeaderFilters *HeaderFiltersContainer
	HTTPBehavior  *httpBehavior
	TrafficLogger *trafficLogger
	// contains filtered or unexported fields
}

Config is the main config mega-struct

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig creates a new mega config object with all default values

func (*Config) EnableOutputDebug added in v2.2.0

func (cfg *Config) EnableOutputDebug()

EnableOutputDebug is the public API to enable debug output

func (*Config) EnableOutputTrace added in v2.2.0

func (cfg *Config) EnableOutputTrace()

EnableOutputTrace is the public API to enable trace output

func (*Config) EnableOutputVerbose added in v2.2.0

func (cfg *Config) EnableOutputVerbose()

EnableOutputVerbose is the public API to enable verbose output

func (*Config) GetLogger added in v2.2.0

func (cfg *Config) GetLogger() *slog.Logger

GetLogger returns the slogger

func (*Config) GetLoggerLevel added in v2.2.0

func (cfg *Config) GetLoggerLevel() slog.Level

GetLoggerLevel returns the current log level

func (*Config) GetTerminalOutputFormat added in v2.2.0

func (cfg *Config) GetTerminalOutputFormat() LogFormat

GetTerminalOutputFormat returns the current traffic log format enum

func (*Config) IsTraceEnabled added in v2.2.0

func (cfg *Config) IsTraceEnabled() bool

IsTraceEnabled returns true if the log is configured to add the source file to the log output

func (*Config) IsVerboseOrHigher

func (cfg *Config) IsVerboseOrHigher() bool

IsVerboseOrHigher returns 1 if the log level is verbose or higher

func (*Config) SetLoggerLevel

func (cfg *Config) SetLoggerLevel()

SetLoggerLevel is the external API to configure the logger with the specified level

func (*Config) SetTerminalOutputFormat added in v2.2.0

func (cfg *Config) SetTerminalOutputFormat(terminalLogFormat string) (LogFormat, error)

SetTerminalOutputFormat sets the terminal output format. It turns an unformatted string from user input into an enum, and will return an error if the input string is not supported.

func (*Config) SetTrafficLogFormat added in v2.2.0

func (cfg *Config) SetTrafficLogFormat(logfmt string) error

SetTrafficLogFormat sets the traffic log format. It turns an unformatted string from user input into an enum, and will return an error if the input string is not supported.

type HeaderFilterGroup added in v2.3.0

type HeaderFilterGroup struct {
	Headers []string // user-editable list of headers to filter
	// contains filtered or unexported fields
}

HeaderFilterGroup is an object used to filter headers for a specific purpose, such as when reading existing logs (remove content-type), writing new logs (remove auth), or when sending requests to upstream.

func NewHeaderFilterGroup added in v2.3.0

func NewHeaderFilterGroup(name string, userHeaders []string, extraHeaders ...[]string) *HeaderFilterGroup

NewHeaderFilterGroup creates a new HeaderFilterGroup

func (*HeaderFilterGroup) FilterHeaders added in v2.3.0

func (hfg *HeaderFilterGroup) FilterHeaders(headers http.Header, additionalHeaders ...string) http.Header

FilterHeaders makes a shallow copy of the headers map and removes any headers that are in the filter group. additionalHeaders is a variadic parameter that allows for additional headers to be removed from the new map that will be returned by this method.

func (*HeaderFilterGroup) IsHeaderInGroup added in v2.3.0

func (hfg *HeaderFilterGroup) IsHeaderInGroup(header string) bool

IsHeaderInGroup returns true if the header should be filtered by this group

func (*HeaderFilterGroup) String added in v2.3.0

func (hfg *HeaderFilterGroup) String() string

type HeaderFiltersContainer added in v2.3.0

type HeaderFiltersContainer struct {
	// Headers set by the upstream, to be filtered from requests stored in the cache
	ResponseToCache *HeaderFilterGroup

	// Headers set by the client, to be omitted from logs
	RequestToLogs *HeaderFilterGroup // filter-request-headers-to-logs

	// Headers set by upstream, to be omitted from logs
	ResponseToLogs *HeaderFilterGroup // filter-response-headers-to-logs

	// Headers set by the client, to be filtered from requests sent upstream
	RequestToUpstream *HeaderFilterGroup // filter-request-headers-to-upstream

	// Headers set by upstream, to be filtered from the responses sent to the client
	ResponseToClient *HeaderFilterGroup // filter-response-headers-to-client
}

HeaderFiltersContainer holds the configuration for filtering headers

func NewHeaderFiltersContainer added in v2.3.0

func NewHeaderFiltersContainer() *HeaderFiltersContainer

NewHeaderFiltersContainer creates a new HeaderFiltersContainer with default values

func (*HeaderFiltersContainer) BuildIndexes added in v2.3.0

func (hg *HeaderFiltersContainer) BuildIndexes()

BuildIndexes rebuilds the internal indexes for the header filters

type LogFormat added in v2.2.0

type LogFormat int

LogFormat is an enum that represents different log formats

const (
	// LogFormatJSON is the JSON log format
	LogFormatJSON LogFormat = iota

	// LogFormatTXT is the plain text log format
	LogFormatTXT
)

func StringToLogFormat added in v2.2.0

func StringToLogFormat(logFormat string) (LogFormat, error)

StringToLogFormat converts a string to a LogLevel enum value.

func (LogFormat) String added in v2.2.0

func (f LogFormat) String() string

type LogSourceConfig

type LogSourceConfig struct {
	LogConnectionStats bool
	LogRequestHeaders  bool
	LogRequest         bool
	LogResponseHeaders bool
	LogResponse        bool
}

LogSourceConfig holds the configuration toggles for logging request and response data

func (*LogSourceConfig) String

func (l *LogSourceConfig) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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