MCPcopy
hub / github.com/caddyserver/caddy / minimalHandler

Function minimalHandler

modules/caddyhttp/reverseproxy/retries_test.go:109–125  ·  view source on GitHub ↗

minimalHandler returns a Handler with only the fields required by ServeHTTP set directly, bypassing Provision (which requires a full Caddy runtime). RoundRobinSelection is used so that successive iterations of the proxy loop advance through the upstream pool in a predictable order.

(retries int, upstreams ...*Upstream)

Source from the content-addressed store, hash-verified

107// RoundRobinSelection is used so that successive iterations of the proxy loop
108// advance through the upstream pool in a predictable order.
109func minimalHandler(retries int, upstreams ...*Upstream) *Handler {
110 return &Handler{
111 logger: zap.NewNop(),
112 Transport: testTransport{&http.Transport{}},
113 Upstreams: upstreams,
114 LoadBalancing: &LoadBalancing{
115 Retries: retries,
116 SelectionPolicy: &RoundRobinSelection{},
117 // RetryMatch intentionally nil: dial errors are always retried
118 // regardless of RetryMatch or request method.
119 },
120 // ctx, connections, connectionsMu, events: zero/nil values are safe
121 // for the code paths exercised by these tests (TryInterval=0 so
122 // ctx.Done() is never consulted; no WebSocket hijacking; no passive
123 // health-check event emission).
124 }
125}
126
127// TestDialErrorBodyRetry verifies that a POST request whose body has NOT been
128// pre-buffered via request_buffers can still be retried after a dial error.

Callers 3

TestDialErrorBodyRetryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected