package httptest

Import Path
	net/http/httptest (on and

Dependency Relation
	imports 19 packages, and imported by 0 packages

Involved Source Files
	d-> httptest.go

Exported Type Names

type ResponseRecorder (struct) ResponseRecorder is an implementation of http.ResponseWriter that records its mutations for later inspection in tests. Body *bytes.Buffer Code int Flushed bool HeaderMap http.Header (*T) Flush() (*T) Header() http.Header (*T) Result() *http.Response (*T) Write(buf []byte) (int, error) (*T) WriteHeader(code int) (*T) WriteString(str string) (int, error) *T : net/http.Flusher *T : net/http.ResponseWriter *T : io.StringWriter *T : io.Writer func NewRecorder() *ResponseRecorder
type Server (struct) A Server is an HTTP server listening on a system-chosen port on the local loopback interface, for use in end-to-end HTTP tests. Config *http.Server EnableHTTP2 bool Listener net.Listener TLS *tls.Config URL string (*T) Certificate() *x509.Certificate (*T) Client() *http.Client (*T) Close() (*T) CloseClientConnections() (*T) Start() (*T) StartTLS() func NewServer(handler http.Handler) *Server func NewTLSServer(handler http.Handler) *Server func NewUnstartedServer(handler http.Handler) *Server
Exported Values
const DefaultRemoteAddr = "" DefaultRemoteAddr is the default remote address to return in RemoteAddr if an explicit DefaultRemoteAddr isn't set on ResponseRecorder.
func NewRecorder() *ResponseRecorder NewRecorder returns an initialized ResponseRecorder.
func NewRequest(method, target string, body io.Reader) *http.Request NewRequest returns a new incoming server Request, suitable for passing to an http.Handler for testing. The target is the RFC 7230 "request-target": it may be either a path or an absolute URL. If target is an absolute URL, the host name from the URL is used. Otherwise, "" is used. The TLS field is set to a non-nil dummy value if target has scheme "https". The Request.Proto is always HTTP/1.1. An empty method means "GET". The provided body may be nil. If the body is of type *bytes.Reader, *strings.Reader, or *bytes.Buffer, the Request.ContentLength is set. NewRequest panics on error for ease of use in testing, where a panic is acceptable. To generate a client HTTP request instead of a server request, see the NewRequest function in the net/http package.
func NewServer(handler http.Handler) *Server NewServer starts and returns a new Server. The caller should call Close when finished, to shut it down.
func NewTLSServer(handler http.Handler) *Server NewTLSServer starts and returns a new Server using TLS. The caller should call Close when finished, to shut it down.
func NewUnstartedServer(handler http.Handler) *Server NewUnstartedServer returns a new Server but doesn't start it. After changing its configuration, the caller should call Start or StartTLS. The caller should call Close when finished, to shut it down.