Documentation
¶
Overview ¶
Package faultproxy is an HTTP proxy that live tests put in front of a backend (a container such as Helix, an S3 server or Azurite) to fail its traffic at the network. With no rule set, the proxy forwards every request. A rule makes it refuse, reset, cut a response in the middle of its body, hang, or answer with a status and body of its own, for every request or for the requests that match.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fault ¶
type Fault struct {
// contains filtered or unexported fields
}
Fault is what the proxy does with a matched request.
func Cut ¶
Cut forwards the request, sends the response headers and the first n bytes of the body, then closes the connection. The client reads an unexpected EOF in the middle of the body.
func Hang ¶
func Hang() Fault
Hang holds the request and does not answer until the client stops waiting.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy forwards to one backend and applies the rule that is set.
func Start ¶
Start starts a proxy in front of target, the backend's base URL. The proxy stops when t ends.
func (*Proxy) Clear ¶
func (p *Proxy) Clear()
Clear removes the rule: the proxy forwards every request again.
type Rule ¶
type Rule struct {
// Match chooses the requests. Nil matches every request. Match can read
// the request body: the proxy gives the body again to the backend.
Match func(*http.Request) bool
Fault Fault
// Once applies the fault to one request only, then clears the rule.
Once bool
}
Rule chooses the requests that get a fault.