Documentation ¶
Index ¶
- type Caction
- type Cdump
- type Cheader
- type Config
- type Creator
- type Creplacement
- type CtokenAction
- type Factory
- type Filter
- func (f *Filter) IsConcerned(ip net.IP, parsedHeader http.Header) bool
- func (f *Filter) IsConditional() bool
- func (f *Filter) Kind() Type
- func (f *Filter) PrefixReplace(URL string) string
- func (f *Filter) Serve(res http.ResponseWriter, req *http.Request)
- func (f *Filter) ServeTCP() error
- func (f *Filter) UpdateRequest(r *http.Request)
- func (f *Filter) UpdateResponse(r *http.Response) error
- type FilteredServer
- type Mock
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Caction ¶ added in v1.3.1
type Caction struct { Replace []Creplacement `yaml:"replace" json:"replace"` Header []Cheader `yaml:"header" json:"header"` }
Caction configuration parts for request and response management.
type Cdump ¶ added in v1.3.1
type Cdump struct { Folder string `yaml:"folder" json:"folder"` URLs []string `yaml:"urls" json:"urls"` }
Cdump configuration parts for dump log.
type Cheader ¶ added in v1.3.1
type Cheader struct { Name string `yaml:"name" json:"name"` Value string `yaml:"value" json:"value"` Force bool `yaml:"force" json:"force"` Add bool `yaml:"add" json:"add"` UUID bool `yaml:"uuid" json:"uuid"` }
Cheader configuration parts for header management.
type Config ¶ added in v1.3.1
type Config struct { ContentTypes []string `yaml:"content-types" json:"content-types"` //nolint: tagliatelle Dump Cdump `yaml:"dump" json:"dump"` Force bool `yaml:"force" json:"force"` Insecure bool `yaml:"insecure" json:"insecure"` Port int `yaml:"port" json:"port"` Prefix []Creplacement `yaml:"prefix" json:"prefix"` Priority uint8 `yaml:"priority" json:"priority"` Replace []Creplacement `yaml:"replace" json:"replace"` Request Caction `yaml:"request" json:"request"` Response Caction `yaml:"response" json:"response"` Restricted []string `yaml:"restricted" json:"restricted"` Status []string `yaml:"status" json:"status"` Token []CtokenAction `yaml:"token" json:"token"` Type string `yaml:"type" json:"type"` URL string `yaml:"url" json:"url"` }
Config common structure for configuration regardless the source.
type Creator ¶ added in v1.4.0
type Creator interface { NewFromYAML(string) (string, uint8, FilteredServer) NewFromJSON(string) (string, uint8, FilteredServer) NewFromEnv() (string, uint8, FilteredServer) }
Creator allow mocking of Factory.
func NewFactory ¶ added in v1.4.0
func NewFactory(upLog logrus.FieldLogger) Creator
NewFactory returns a Filter Factory.
type Creplacement ¶ added in v1.3.1
type Creplacement struct { From string `yaml:"from" json:"from"` To string `yaml:"to" json:"to"` Urls []string `yaml:"urls" json:"urls"` }
Creplacement configuration parts for replacement.
type CtokenAction ¶ added in v1.3.1
type CtokenAction struct { Header string `yaml:"header" json:"header"` Value string `yaml:"value" json:"value"` Action string `yaml:"action" json:"action"` }
CtokenAction configuration parts for token management.
type Factory ¶ added in v1.4.0
type Factory struct {
// contains filtered or unexported fields
}
Factory provides way to create a filters.
func (*Factory) NewFromEnv ¶ added in v1.4.0
func (f *Factory) NewFromEnv() (string, uint8, FilteredServer)
NewFromEnv instantiate a Filter object from the environment variable configuration. nolint: funlen,gocognit
func (*Factory) NewFromJSON ¶ added in v1.4.0
func (f *Factory) NewFromJSON(filePath string) (string, uint8, FilteredServer)
NewFromJSON instantiate a Filter object from the configuration file.
func (*Factory) NewFromYAML ¶ added in v1.4.0
func (f *Factory) NewFromYAML(filePath string) (string, uint8, FilteredServer)
NewFromYAML instantiate a Filter object from the configuration file.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter proxifies an URL and filter the response.
func (*Filter) IsConcerned ¶ added in v1.1.0
IsConcerned determine if the request fulfil the filter condition.
func (*Filter) IsConditional ¶ added in v1.1.0
IsConditional returns true if the filter has conditions.
func (*Filter) PrefixReplace ¶ added in v1.4.0
PrefixReplace rewrite the current URL with the defined URL prefixes.
func (*Filter) Serve ¶
func (f *Filter) Serve(res http.ResponseWriter, req *http.Request)
Serve starts a filtering http proxy.
func (*Filter) ServeTCP ¶ added in v1.4.0
ServeTCP listen on the given port and start a goroutine to handle each connection.
func (*Filter) UpdateRequest ¶ added in v1.0.2
UpdateRequest will be called back when the request is received by the proxy.
type FilteredServer ¶ added in v1.4.0
type FilteredServer interface { IsConcerned(net.IP, http.Header) bool Serve(http.ResponseWriter, *http.Request) ServeTCP() error IsConditional() bool PrefixReplace(string) string Kind() Type }
FilteredServer represents a reverse proxy.
type Mock ¶ added in v1.4.0
type Mock struct { Position int Concerned bool Conditional bool T *testing.T // contains filtered or unexported fields }
Mock provides a way to mimic a Filter object.
func NewMock ¶ added in v1.4.0
func NewMock( kind Type, position int, concerned bool, conditional bool, reqBody string, reqHeader http.Header, resBody string, resHeader http.Header, t *testing.T, ) *Mock
NewMock returns a new mock.
func (*Mock) IsConcerned ¶ added in v1.4.0
IsConcerned mimics the IsConcerned from Filter.
func (*Mock) IsConditional ¶ added in v1.4.0
IsConditional mimics the IsConditional from Filter.
func (*Mock) PrefixReplace ¶ added in v1.4.0
PrefixReplace mimics the PrefixReplace from Filter.