shared

package
v0.0.0-...-b038a85 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigKey = "config"
View Source
const IndexFile = "index.html"
View Source
const UIAssetsLocation = "ui/dist/assets"
View Source
const UILocation = "ui/dist"
View Source
const WiretapHostPlaceholder = "%WIRETAP_HOST%"
View Source
const WiretapPortPlaceholder = "%WIRETAP_PORT%"
View Source
const WiretapTLSPlaceholder = "%WIRETAP_TLS%"
View Source
const WiretapVersionPlaceholder = "%WIRETAP_VERSION%"

Variables

This section is empty.

Functions

func MarshalError

func MarshalError(err *WiretapError) []byte

func Pluralize

func Pluralize(n int, singular string, plural string) string

Types

type CompiledPath

type CompiledPath struct {
	PathConfig          *WiretapPathConfig
	CompiledKey         glob.Glob
	CompiledTarget      glob.Glob
	CompiledPathRewrite map[string]*regexp.Regexp
}

type CompiledPathDelay

type CompiledPathDelay struct {
	CompiledPathDelay glob.Glob
	PathDelayValue    int
}

type CompiledPathRewrite

type CompiledPathRewrite struct {
	PathConfig     *WiretapPathConfig
	Key            string
	CompiledKey    glob.Glob
	CompiledTarget glob.Glob
}

type CompiledVariable

type CompiledVariable struct {
	CompiledVariable *regexp.Regexp
	VariableValue    string
}

type WiretapConfiguration

type WiretapConfiguration struct {
	Contract            string                        `json:"-" yaml:"-"`
	RedirectHost        string                        `json:"redirectHost,omitempty" yaml:"redirectHost,omitempty"`
	RedirectPort        string                        `json:"redirectPort,omitempty" yaml:"redirectPort,omitempty"`
	RedirectBasePath    string                        `json:"redirectBasePath,omitempty" yaml:"redirectBasePath,omitempty"`
	RedirectProtocol    string                        `json:"redirectProtocol,omitempty" yaml:"redirectProtocol,omitempty"`
	RedirectURL         string                        `json:"redirectURL,omitempty" yaml:"redirectURL,omitempty"`
	Port                string                        `json:"port,omitempty" yaml:"port,omitempty"`
	MonitorPort         string                        `json:"monitorPort,omitempty" yaml:"monitorPort,omitempty"`
	WebSocketHost       string                        `json:"webSocketHost,omitempty" yaml:"webSocketHost,omitempty"`
	WebSocketPort       string                        `json:"webSocketPort,omitempty" yaml:"webSocketPort,omitempty"`
	GlobalAPIDelay      int                           `json:"globalAPIDelay,omitempty" yaml:"globalAPIDelay,omitempty"`
	StaticDir           string                        `json:"staticDir,omitempty" yaml:"staticDir,omitempty"`
	StaticIndex         string                        `json:"staticIndex,omitempty" yaml:"staticIndex,omitempty"`
	PathConfigurations  map[string]*WiretapPathConfig `json:"paths,omitempty" yaml:"paths,omitempty"`
	Headers             *WiretapHeaderConfig          `json:"headers,omitempty" yaml:"headers,omitempty"`
	StaticPaths         []string                      `json:"staticPaths,omitempty" yaml:"staticPaths,omitempty"`
	Variables           map[string]string             `json:"variables,omitempty" yaml:"variables,omitempty"`
	Spec                string                        `json:"contract,omitempty" yaml:"contract,omitempty"`
	Certificate         string                        `json:"certificate,omitempty" yaml:"certificate,omitempty"`
	CertificateKey      string                        `json:"certificateKey,omitempty" yaml:"certificateKey,omitempty"`
	HardErrors          bool                          `json:"hardValidation,omitempty" yaml:"hardValidation,omitempty"`
	HardErrorCode       int                           `json:"hardValidationCode,omitempty" yaml:"hardValidationCode,omitempty"`
	HardErrorReturnCode int                           `json:"hardValidationReturnCode,omitempty" yaml:"hardValidationReturnCode,omitempty"`
	PathDelays          map[string]int                `json:"pathDelays,omitempty" yaml:"pathDelays,omitempty"`
	MockMode            bool                          `json:"mockMode,omitempty" yaml:"mockMode,omitempty"`
	MockModePretty      bool                          `json:"mockModePretty,omitempty" yaml:"mockModePretty,omitempty"`
	Base                string                        `json:"base,omitempty" yaml:"base,omitempty"`
	HAR                 string                        `json:"har,omitempty" yaml:"har,omitempty"`
	HARValidate         bool                          `json:"harValidate,omitempty" yaml:"harValidate,omitempty"`
	CompiledPathDelays  map[string]*CompiledPathDelay `json:"-" yaml:"-"`
	CompiledVariables   map[string]*CompiledVariable  `json:"-" yaml:"-"`
	Version             string                        `json:"-" yaml:"-"`
	StaticPathsCompiled []glob.Glob                   `json:"-" yaml:"-"`
	CompiledPaths       map[string]*CompiledPath      `json:"-"`
	FS                  embed.FS                      `json:"-"`
	Logger              *slog.Logger
}

func (*WiretapConfiguration) CompilePathDelays

func (wtc *WiretapConfiguration) CompilePathDelays()

func (*WiretapConfiguration) CompilePaths

func (wtc *WiretapConfiguration) CompilePaths()

func (*WiretapConfiguration) CompileVariables

func (wtc *WiretapConfiguration) CompileVariables()

func (*WiretapConfiguration) ReplaceWithVariables

func (wtc *WiretapConfiguration) ReplaceWithVariables(input string) string

type WiretapError

type WiretapError struct {
	Type     string `json:"type,omitempty"`     // URI reference to the type of problem
	Title    string `json:"title"`              // A short description of the issue
	Status   int    `json:"status,omitempty"`   // HTTP status code.
	Detail   string `json:"detail"`             // explanation of the issue in detail.
	Instance string `json:"instance,omitempty"` // URI to the specific problem.
	Payload  any    `json:"payload,omitempty"`  // if added, this is the payload that caused the error
}

WiretapError is an rfc7807 compliant error struct

func GenerateError

func GenerateError(title string,
	status int,
	detail string,
	instance string, payload any) *WiretapError

type WiretapHeaderConfig

type WiretapHeaderConfig struct {
	DropHeaders    []string          `json:"drop,omitempty" yaml:"drop,omitempty"`
	InjectHeaders  map[string]string `json:"inject,omitempty" yaml:"inject,omitempty"`
	RewriteHeaders map[string]string `json:"rewrite,omitempty" yaml:"rewrite,omitempty"`
}

type WiretapPathConfig

type WiretapPathConfig struct {
	Target       string               `json:"target,omitempty" yaml:"target,omitempty"`
	PathRewrite  map[string]string    `json:"pathRewrite,omitempty" yaml:"pathRewrite,omitempty"`
	ChangeOrigin bool                 `json:"changeOrigin,omitempty" yaml:"changeOrigin,omitempty"`
	Headers      *WiretapHeaderConfig `json:"headers,omitempty" yaml:"headers,omitempty"`
	Secure       bool                 `json:"secure,omitempty" yaml:"secure,omitempty"`
	Auth         string               `json:"auth,omitempty" yaml:"auth,omitempty"`
	CompiledPath *CompiledPath        `json:"-"`
}

func (*WiretapPathConfig) Compile

func (wpc *WiretapPathConfig) Compile(key string) *CompiledPath

Jump to

Keyboard shortcuts

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