Skip to main content

internal/conformance/proxy.go

internal/conformance · 89 lines · 7 declarations · source

Declarations

type Recorded

type Recorded struct {
Method string
Path string
Body []byte
}

Recorded is one request the adapter made through the proxy.

source

type proxy

type proxy struct {
server *httptest.Server
mu sync.Mutex
faults Faults
context *ContextAnswer
log []Recorded
}

proxy stands between the driver and the deployment. It forwards everything, records what the adapter sent, and refuses the operations a case's faults name with 503, which is what a deployment behind a load balancer answers when it is down: the same status an adapter has to treat as "memory unavailable" in production.

source

func newProxy

func newProxy(target string) (*proxy, error)

source

method proxy.URL

func (p *proxy) URL() string

source

method proxy.Close

func (p *proxy) Close()

source

method proxy.begin

func (p *proxy) begin(faults Faults, answer *ContextAnswer)

begin arms the faults and the stated context for one case and clears the log.

source

method proxy.recorded

func (p *proxy) recorded() []Recorded

source