mockrest

package
v0.0.0-...-5d654d2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

mockrest is scriptable server which wraps httptest. Allows for client testing by responding back with appropriate schemas

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	URL string
	// contains filtered or unexported fields
}

Server holds state relaced to the handlers and tests.

func New

func New() *Server

Create a new Server but don't start it

func StartNewWithBody

func StartNewWithBody(body string) *Server

Create a new Server and start it with the specified body as the response

func StartNewWithFile

func StartNewWithFile(file string) *Server

Start a new server with the specified file as the response

func StartNewWithStatusCode

func StartNewWithStatusCode(status int) *Server

Create a new Server and start it with the specified status as the response

func (*Server) Enqueue

func (s *Server) Enqueue(h http.HandlerFunc)

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Start

func (s *Server) Start() string

Start a Server

func (*Server) Stop

func (s *Server) Stop()

Stop a running Server

func (*Server) TakeRequest

func (s *Server) TakeRequest() *http.Request

func (*Server) TakeRequestWithTimeout

func (s *Server) TakeRequestWithTimeout(duration time.Duration) *http.Request

Jump to

Keyboard shortcuts

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