mock

package
v1.6.5-rc22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResponseWriter

type ResponseWriter struct {
	StatusCode int
	bytes.Buffer
	// contains filtered or unexported fields
}
Example
rw := NewMockResponseWriter()
rw.Header().Set("Content-Type", "application/json")

rw.WriteHeader(http.StatusOK)
rw.Write([]byte(`{"status":"ok"}`))

fmt.Println(string(rw.MustDumpResponse()))
Output:

HTTP/0.0 200 OK
Content-Type: application/json

{"status":"ok"}

func NewMockResponseWriter

func NewMockResponseWriter() *ResponseWriter

func (*ResponseWriter) Header

func (w *ResponseWriter) Header() http.Header

func (*ResponseWriter) MustDumpResponse

func (w *ResponseWriter) MustDumpResponse() []byte

func (*ResponseWriter) Response

func (w *ResponseWriter) Response() *http.Response

func (*ResponseWriter) WriteHeader

func (w *ResponseWriter) WriteHeader(statusCode int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL