domain

package
v0.0.0-...-d46a54d Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProxyServerTransport

func ProxyServerTransport(tlsClientConf *tls.Config) *http.Transport

ProxyServerTransport creates proxy server transport for default settings

Types

type ProxyServer

type ProxyServer struct {
	ID         int64
	Name       string
	Address    url.URL
	IsDefault  bool
	IsReadOnly bool
	Transport  http.RoundTripper
}

ProxyServer is proxy server where request can be proxied

type ProxyServers

type ProxyServers []ProxyServer

ProxyServers is collections type for ProxyServer instances

func ConvertProxyServers

func ConvertProxyServers(conf config.ProxyServerConfigs) (ProxyServers, error)

ConvertProxyServers converts configuration to domain object

func (ProxyServers) Default

func (p ProxyServers) Default() (ProxyServer, bool)

Default finds default server

func (ProxyServers) Find

func (p ProxyServers) Find(name string) (ProxyServer, bool)

Find returns first proxy server matching given name

func (ProxyServers) FindByHost

func (p ProxyServers) FindByHost(host string) (ProxyServer, bool)

FindByHost returns first proxy server matching given host

type Replacement

type Replacement struct {
	Regex *regexp.Regexp
	Value string
}

Replacement describes rules for replacing things in request/response

type Replacements

type Replacements []Replacement

Replacements is collection type for Replacement structures

type Request

type Request struct {
	ID           string
	RuleID       int64
	Service      string
	Request      []byte
	RequestTime  time.Time
	RequestSize  int64
	Response     []byte
	ResponseTime time.Time
	ResponseSize int64
}

Request is cached bodies of proxied request/response

type Rule

type Rule struct {
	ID                   int64
	Server               string
	Service              string
	Priority             int64
	MatcherRemoteAddr    []string
	MatcherRegex         []*regexp.Regexp
	RequestReplacements  Replacements
	ResponseReplacements Replacements
	IsReadOnly           bool
}

Rule describes rules where and when to proxy requests

func (Rule) ApplyRequestReplacements

func (r Rule) ApplyRequestReplacements(body []byte) []byte

ApplyRequestReplacements applies rule request replacements on body

func (Rule) ApplyResponseReplacements

func (r Rule) ApplyResponseReplacements(body []byte) []byte

ApplyResponseReplacements applies rule response replacements on body

type Rules

type Rules []Rule

Rules is collection type for Rule structures

func ConvertRules

func ConvertRules(conf config.RuleConfigs) (Rules, error)

ConvertRules convert configuration to domain object

func (Rules) FindByID

func (r Rules) FindByID(ID int64) (Rule, bool)

FindByID finds rule by ID

func (Rules) MatchRegex

func (r Rules) MatchRegex(requestBody []byte) (Rule, bool)

MatchRegex returns first rule matching its regex

func (Rules) MatchRemoteAddr

func (r Rules) MatchRemoteAddr(remoteAddr string) Rules

MatchRemoteAddr returns slice of Rules matching given remote addr

func (Rules) MatchService

func (r Rules) MatchService(service string) Rules

MatchService returns slice of Rules matching given service name

Jump to

Keyboard shortcuts

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