mockhttp

package
v1.9.51 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockHttp

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

func NewMockedHttpRequest

func NewMockedHttpRequest(method, url string) *MockHttp

func (*MockHttp) Fails

func (i *MockHttp) Fails(message string) *MockHttp

func (*MockHttp) For

func (i *MockHttp) For(comment string) *MockHttp

func (*MockHttp) NotFound

func (i *MockHttp) NotFound() *MockHttp

func (*MockHttp) RedirectsTo

func (i *MockHttp) RedirectsTo(uri string) *MockHttp

func (*MockHttp) Respond

func (i *MockHttp) Respond(writer http.ResponseWriter, logger *log.Logger)

func (*MockHttp) RespondsEmpty

func (i *MockHttp) RespondsEmpty() *MockHttp

func (*MockHttp) RespondsWith

func (i *MockHttp) RespondsWith(body string) *MockHttp

func (*MockHttp) RespondsWithJson

func (i *MockHttp) RespondsWithJson(obj interface{}) *MockHttp

func (*MockHttp) RespondsWithUnauthorized

func (i *MockHttp) RespondsWithUnauthorized(body string) *MockHttp

func (*MockHttp) SetResponseCallback

func (i *MockHttp) SetResponseCallback(b func(rawbody []byte))

func (*MockHttp) SkipAuthentication

func (i *MockHttp) SkipAuthentication() *MockHttp

func (*MockHttp) Url

func (i *MockHttp) Url() string

func (*MockHttp) Verify

func (i *MockHttp) Verify(req *http.Request, d *Server)

func (*MockHttp) WithAuthorizationHeader

func (i *MockHttp) WithAuthorizationHeader(auth string) *MockHttp

func (*MockHttp) WithBody

func (i *MockHttp) WithBody(body string) *MockHttp

func (*MockHttp) WithContentType

func (i *MockHttp) WithContentType(contentType string) *MockHttp

type MockedResponseBuilder

type MockedResponseBuilder interface {
	Verify(req *http.Request, d *Server)
	Respond(writer http.ResponseWriter, logger *log.Logger)
	Url() string
}

type Server

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

func StartServer

func StartServer(name string, startTestServer func(http.Handler) *httptest.Server) *Server

func (*Server) ExpectedAuthorizationHeader

func (d *Server) ExpectedAuthorizationHeader(header string)

func (*Server) ExpectedBasicAuth

func (d *Server) ExpectedBasicAuth(username, password string)

func (*Server) ServeHTTP

func (d *Server) ServeHTTP(writer http.ResponseWriter, req *http.Request)

func (*Server) VerifyAndMock

func (d *Server) VerifyAndMock(mockedResponses ...MockedResponseBuilder)

func (*Server) VerifyMocks

func (d *Server) VerifyMocks()

Jump to

Keyboard shortcuts

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