mock

package
v0.0.0-...-2c78349 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResponse

func NewResponse(statusCode int, body string) *http.Response

NewResponse create a new response.

func NoVerifyTransport

func NoVerifyTransport() *http.Transport

NoVerifyTransport return transport that skip the certificate verification.

Types

type Server

type Server struct {
	*httptest.Server
	// contains filtered or unexported fields
}

Server a mock server to capture request to API.

func NewServer

func NewServer() *Server

NewServer create and start a new mock Server.

func (*Server) Host

func (ms *Server) Host() string

Host return the url without the method (URN).

func (*Server) SetResponse

func (ms *Server) SetResponse(resp *http.Response)

SetResponse set the response for the incoming requests. The method cached the response body value and reset the body to support

multiple times of requests.

func (*Server) SetResponseHandler

func (ms *Server) SetResponseHandler(handler func(r *http.Request) *http.Response)

SetResponseHandler set a handler to update reponse base on request info.

Jump to

Keyboard shortcuts

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