http

package
v6.2.13 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetResponseBody

func GetResponseBody(t *testing.T, visitor func(http.ResponseWriter) error) string

func GetResponseBodyBytes

func GetResponseBodyBytes(t *testing.T, visitor func(http.ResponseWriter) error) []byte

func TestTLSServer

func TestTLSServer(t *testing.T, handler http.Handler) *httptest.Server

func UnmarshalResponseBody

func UnmarshalResponseBody(t *testing.T, visitor func(http.ResponseWriter) error, target interface{})

Types

type Handler

type Handler struct {
	Request        *http.Request
	RequestHeaders http.Header
	RequestQuery   url.Values
	StatusCode     int
	RequestData    []byte
	ResponseData   interface{}
	ResponseHeader http.Header
}

Handler is a custom http handler useful in testing. Usage:

s := httptest.NewServer(handler{statusCode: http.StatusOK, responseData: someStruct})

Then s.URL must be configured in the client.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(writer http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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