Documentation
¶
Index ¶
- Constants
- func Get(addr, path string) (*http.Response, error)
- func ListenAndServe(addr string, handler http.Handler) error
- func MarshalRequest(req *http.Request) ([]byte, error)
- func MarshalResponse(resp *http.Response) ([]byte, error)
- func UnmarshalRequest(b []byte) (*http.Request, error)
- func UnmarshalResponse(b []byte) (*http.Response, error)
- type Server
- type Transport
Constants ¶
const ( FrameRequest uint16 = 0x01 FrameResponse uint16 = 0x02 )
Frame type IDs. The ZAP message header carries the type in the upper byte of the 16-bit flags field; FinishWithFlags(t<<8) tags the message and Message.Flags()>>8 recovers it. A request frame and a response frame are the two shapes the wire carries today.
const MaxFrameSize = 64 << 20 // 64 MiB
MaxFrameSize bounds an inbound frame. The wire format leaves room for larger frames; the limit here defends a server against a malicious peer announcing a multi-gigabyte length prefix.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
Get is a convenience for transports that don't need an http.Client wrapper (e.g. service-to-service calls inside a cluster).
func ListenAndServe ¶
ListenAndServe is the convenience equivalent of net/http.ListenAndServe.
func MarshalRequest ¶
MarshalRequest serializes an *http.Request into a ZAP frame. The returned bytes are framed and ready for transport.Write — the transport layer prepends the length prefix.
The body is fully read and consumed; callers that need to reuse the request must replace req.Body with a fresh reader after this call.
func MarshalResponse ¶
MarshalResponse serializes an *http.Response into a ZAP frame.
func UnmarshalRequest ¶
UnmarshalRequest reconstructs an *http.Request from a ZAP frame. The returned request has Body set to a bytes.Reader over the frame's body bytes; the request URL is parsed from target. Host is taken from the request's Host header (RFC 9110 §7.2).
Types ¶
type Server ¶
type Server struct {
Addr string // ":9999" if empty
Handler http.Handler // http.DefaultServeMux if nil
ReadTimeout time.Duration // 0 means no timeout
WriteTimeout time.Duration
IdleTimeout time.Duration
MaxHeaderBytes int // not enforced today; placeholder for parity
// contains filtered or unexported fields
}
Server is a ZAP-HTTP server. Zero-value is usable; common knobs (Addr, Handler, ReadTimeout, …) mirror net/http.Server.
func (*Server) ListenAndServe ¶
ListenAndServe binds Addr and serves until Close is called or a fatal accept error occurs.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport implements http.RoundTripper over a ZAP-HTTP TCP connection. Field-zero is invalid; use NewTransport.
func NewTransport ¶
NewTransport returns a Transport connecting to the given host:port.
func (*Transport) CloseIdleConnections ¶
func (t *Transport) CloseIdleConnections()
CloseIdleConnections closes every idle conn in the pool. Active requests are unaffected. Useful in tests + on shutdown.
func (*Transport) SetDialTimeout ¶
SetDialTimeout overrides the default 10s dial timeout.
func (*Transport) SetMaxIdleConns ¶
SetMaxIdleConns caps the number of idle conns held in the pool. Surplus conns close on return.
func (*Transport) SetReadTimeout ¶
SetReadTimeout overrides the default 30s response-read timeout.