mockhttp

package
v0.0.0-...-fb356ce Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

func NewMockedHttpRequest

func NewMockedHttpRequest(method, url string) *Handler

func (*Handler) DelayResponse

func (i *Handler) DelayResponse(delay time.Duration) *Handler

func (*Handler) For

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

func (*Handler) RedirectsTo

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

func (*Handler) Respond

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

func (*Handler) RespondsAcceptedWith

func (i *Handler) RespondsAcceptedWith(body string) *Handler

func (*Handler) RespondsConflict

func (i *Handler) RespondsConflict() *Handler

func (*Handler) RespondsCreated

func (i *Handler) RespondsCreated() *Handler

func (*Handler) RespondsForbiddenWith

func (i *Handler) RespondsForbiddenWith(body string) *Handler

func (*Handler) RespondsInternalServerErrorWith

func (i *Handler) RespondsInternalServerErrorWith(body string) *Handler

func (*Handler) RespondsNoContent

func (i *Handler) RespondsNoContent() *Handler

func (*Handler) RespondsNotFoundWith

func (i *Handler) RespondsNotFoundWith(body string) *Handler

func (*Handler) RespondsOKWith

func (i *Handler) RespondsOKWith(body string) *Handler

func (*Handler) RespondsOKWithJSON

func (i *Handler) RespondsOKWithJSON(obj interface{}) *Handler

func (*Handler) RespondsUnauthorizedWith

func (i *Handler) RespondsUnauthorizedWith(body string) *Handler

func (*Handler) RunsFunction

func (i *Handler) RunsFunction(expectedFunction func()) *Handler

func (*Handler) Url

func (i *Handler) Url() string

func (*Handler) Verify

func (i *Handler) Verify(req *http.Request, s *Server)

func (*Handler) WithAuthorizationHeader

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

func (*Handler) WithBody

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

func (*Handler) WithContentType

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

func (*Handler) WithHeader

func (i *Handler) WithHeader(header, value string) *Handler

func (*Handler) WithHeaderPresent

func (i *Handler) WithHeaderPresent(header string) *Handler

func (*Handler) WithJSONBody

func (i *Handler) WithJSONBody(body string) *Handler

func (*Handler) WithRegexURLMatcher

func (i *Handler) WithRegexURLMatcher() *Handler

func (*Handler) WithoutHeader

func (i *Handler) WithoutHeader(header string) *Handler

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) *Server

func StartTLSServer

func StartTLSServer(name, certPath, keyPath string) *Server

func (*Server) AppendMocks

func (s *Server) AppendMocks(mockedResponses ...MockedResponseBuilder)

func (*Server) ExcludeAuthorizationCheck

func (s *Server) ExcludeAuthorizationCheck(path string)

func (*Server) ExpectedAuthorizationHeader

func (s *Server) ExpectedAuthorizationHeader(header string)

func (*Server) ExpectedBasicAuth

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

func (*Server) ServeHTTP

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

func (*Server) VerifyAndMock

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

func (*Server) VerifyMocks

func (s *Server) VerifyMocks()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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