Standard library / net/http

http.NewResponseController()

Creates a response controller for the active handler response writer. Unsupported operations return an error matching ErrNotSupported. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func NewResponseController(rw ResponseWriter) *ResponseController

Parameters & Attributes

NameTypeDescription
rwResponseWriterResponseWriter for the currently active request.

Return Value

*ResponseController

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/http"  "net/http/httptest")
func main() {  w := httptest.NewRecorder()  c := http.NewResponseController(w)  check(c.Flush())  fmt.Println(w.Flushed)}
func must[T any](v T, e error) T {  if e != nil {    panic(e)  }  return v}func check(e error) {  if e != nil {    panic(e)  }}
Go Reference