ServeHTTP unmarshals JSON input, handles the request via the function, and marshals JSON output. If the output of the handler function implements io.Reader the headers must contain a 'Content-Type'; the stream will be written directly to the requestor without being marshaled to JSON. Additionally if the output implements the io.Closer the stream will be automatically closed after flushing.

ServeHTTP is referenced in 1 repository