liveBook · Manning

Http.ResponseWriter

http.ResponseWriter is the Go interface through which an HTTP handler constructs a response by writing its headers, status, and body.

How 2 Manning books explain it

Learn Go with Pocket-Sized Projects

http.ResponseWriter is a Go interface through which an HTTP handler constructs a response, including its headers, status, and body.

How it is used
Builds the headers, status, and body returned by Go HTTP handlers.
How deep it goes
Explains write ordering and defaults through handlers and tests, without implementing the interface itself.
Examples
Uses a POST /games JSON response, a plain-text or HTML page, and a controlled test-server response.
What you can do after
Build it from scratch: write handler responses with the intended headers and status, then test them with httptest.NewRecorder().

Read how Learn Go with Pocket-Sized Projects explains http.ResponseWriter →

Go by Example

http.ResponseWriter is the Go HTTP interface through which a handler constructs an HTTP response and accesses connection-related response behavior.

How it is used
Constructs HTTP responses inside handlers and supplies a test seam for observing them.
How deep it goes
Defines core response methods, ordering, default status behavior, testing, optional interfaces, and wrapper unwrapping.
Examples
Uses an OK health endpoint, a ResponseRecorder test, conditional flushing, and oversized-request connection closure.
What you can do after
Apply it via the net/http package to send, test, flush, and unwrap handler responses.

Read how Go by Example explains http.ResponseWriter →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.