httpmock

package
v0.0.0-...-7426b64 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeActivate

func DeActivate()

DeActivate the httpmock

func Register

func Register(method string, request string)

Register defers to the default HTTPMock's Register or errors if no default defined.

func RegisterWithCode

func RegisterWithCode(method string, request string, code int)

RegisterWithCode defers to the default HTTPMock's RegisterWithCode or errors if no default defined.

func RegisterWithResponder

func RegisterWithResponder(method string, request string, cb func(req *http.Request) (int, string))

RegisterWithResponder defers to the default HTTPMock's RegisterWithResponder or errors if no default defined.

func RegisterWithResponderBody

func RegisterWithResponderBody(method string, request string, code int, cb func(req *http.Request) (int, string))

RegisterWithResponderBody defers to the default HTTPMock's RegisterWithResponderBody or errors if no default defined.

func RegisterWithResponse

func RegisterWithResponse(method string, request string, code int, responseFile string)

RegisterWithResponse defers to the default HTTPMock's RegisterWithResponse or errors if no default defined.

func RegisterWithResponseBody

func RegisterWithResponseBody(method string, request string, code int, responseBody string)

RegisterWithResponseBody defers to the default HTTPMock's RegisterWithResponseBody or errors if no default defined.

func RegisterWithResponseBytes

func RegisterWithResponseBytes(method string, request string, code int, responseBytes []byte)

RegisterWithResponseBytes defers to the default HTTPMock's RegisterWithResponseBytes or errors if no default defined.

Types

type HTTPMock

type HTTPMock struct {
	// contains filtered or unexported fields
}

HTTPMock encapsulate the functionality for mocking requests to a specific base-url.

func Activate

func Activate(prefix string) *HTTPMock

Activate an and return an *HTTPMock instance. If none yet activated, then the first becomes the default HTTPMock; which means you can just call package funcs to use it.

func (*HTTPMock) Register

func (mock *HTTPMock) Register(method string, request string)

Register registers a httpmock for the given request (the response file is based on the request)

func (*HTTPMock) RegisterWithCode

func (mock *HTTPMock) RegisterWithCode(method string, request string, code int)

RegisterWithCode is the same as Register but it allows specifying a code

func (*HTTPMock) RegisterWithResponder

func (mock *HTTPMock) RegisterWithResponder(method string, request string, cb func(req *http.Request) (int, string))

RegisterWithResponder register a httpmock with a custom responder

func (*HTTPMock) RegisterWithResponderBody

func (mock *HTTPMock) RegisterWithResponderBody(method string, request string, cb func(req *http.Request) (int, string))

RegisterWithResponderBody register a httpmock with a custom responder that returns the response body

func (*HTTPMock) RegisterWithResponse

func (mock *HTTPMock) RegisterWithResponse(method string, request string, code int, responseFile string)

RegisterWithResponse is the same as RegisterWithCode but it allows specifying a response file

func (*HTTPMock) RegisterWithResponseBody

func (mock *HTTPMock) RegisterWithResponseBody(method string, request string, code int, responseBody string)

RegisterWithResponseBody will respond with the given code and responseBody, no external files involved

func (*HTTPMock) RegisterWithResponseBytes

func (mock *HTTPMock) RegisterWithResponseBytes(method string, request string, code int, responseBytes []byte)

RegisterWithResponseBytes will respond with the given code and responseBytes, no external files involved

Jump to

Keyboard shortcuts

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