Documentation
¶
Overview ¶
Package httpkit holds shared HTTP transport helpers for the API surfaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteSSEHeaders ¶
func WriteSSEHeaders(w http.ResponseWriter)
WriteSSEHeaders sets the Server-Sent Events headers shared by every streaming endpoint. Callers still own WriteHeader and Flush.
Types ¶
type StreamWriter ¶ added in v0.6.9
type StreamWriter struct {
// contains filtered or unexported fields
}
StreamWriter is the single owner of streaming response commitment. The 200 status and SSE headers go out with the first byte, not before routing: a failure before any output (unknown provider, no credential, rate limit) still answers with its real HTTP status and headers such as Retry-After. Every write flushes, so each event reaches the client immediately instead of waiting in the server's output buffer.
func NewStreamWriter ¶ added in v0.6.9
func NewStreamWriter(w http.ResponseWriter) (stream *StreamWriter, ok bool)
NewStreamWriter wraps w. ok is false when w cannot flush: the caller then answers with a plain error instead of streaming.
func (*StreamWriter) Flush ¶ added in v0.6.9
func (s *StreamWriter) Flush()
Flush flushes committed output. Before the first byte it does nothing, so an early flush never commits a 200.
func (*StreamWriter) Started ¶ added in v0.6.9
func (s *StreamWriter) Started() bool
Started reports whether the stream committed (status 200 sent). Once true, failures must be reported inside the stream.