Documentation ¶
Index ¶
- func EnsureTransporterFinalized(httpTransport *http.Transport)
- func NewReplayRequest(req *http.Request, host string, body io.Reader) (*http.Request, error)
- type Filter
- type Handler
- type Modifier
- type Replayer
- func (x *Replayer) Filter(fn ...Filter) *Replayer
- func (x *Replayer) HandleHTTP(w http.ResponseWriter, r *http.Request, h http.Handler)
- func (x *Replayer) Modify(fn ...Modifier) *Replayer
- func (x *Replayer) Replay(r *http.Request, target string, body io.Reader)
- func (x *Replayer) SetHandler(fn Handler) *Replayer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureTransporterFinalized ¶
EnsureTransporterFinalized will ensure that when the HTTP client is GCed the runtime will close the idle connections (so that they won't leak) this function was adopted from Hashicorp's go-cleanhttp package.
Types ¶
type Filter ¶
Filter function is used to determine if a given http.Request should be replayed or not.
type Replayer ¶
type Replayer struct { // Targets stores the replay URL targets. Targets []string // Filters stores the replay filter functions. Filters []Filter // Modifiers stores the replay request modifier functions. Modifiers []Modifier // Handler stores the optional replay response/error handler. Handler Handler // Client stores the http.Client to be used to replay the requests. // Defaults to http.DefaultClient. Client *http.Client }
Replayer replays incoming HTTP traffic to one or multiple servers via isolated goroutine.
func (*Replayer) Filter ¶
Filter attaches a new filter function to the current replayer who determines if a given request should be replayed or not.
func (*Replayer) HandleHTTP ¶
HandleHTTP handles an incoming HTTP request received by the proxy.
func (*Replayer) Modify ¶
Modify attaches a new modifier function to the current replayer who is responsible to modify the http.Request to be replayed before the replay.
func (*Replayer) SetHandler ¶
SetHandler is used to set a replay request handler, allowing the developer to deal with the replay response or error accordingly.