route

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RequestRouter

type RequestRouter struct {
	Mocks    []definition.Mock
	Matcher  match.Matcher
	DUpdates chan []definition.Mock
	sync.Mutex
}

RequestRouter checks http requesta and try to figure out what is the best mock for each one.

func NewRouter

func NewRouter(mocks []definition.Mock, matcher match.Matcher, dUpdates chan []definition.Mock) *RequestRouter

NewRouter returns a pointer to new RequestRouter

func (*RequestRouter) Copy added in v1.0.0

func (rr *RequestRouter) Copy(src, dst *definition.Mock)

func (*RequestRouter) MockChangeWatch

func (rr *RequestRouter) MockChangeWatch()

MockChangeWatch monitors the mock configuration dir and loads again all the mocks it something change.

func (*RequestRouter) Route

func (rr *RequestRouter) Route(req *definition.Request) (*definition.Mock, map[string]string)

Route checks the request with all available mock definitions and return the matching mock for it.

func (*RequestRouter) SetMockDefinitions

func (rr *RequestRouter) SetMockDefinitions(mocks []definition.Mock)

SetMockDefinitions allows replace the current mock definitions for new ones.

type Router

type Router interface {
	Route(req *definition.Request) (*definition.Mock, map[string]string)
	SetMockDefinitions(mocks []definition.Mock)
}

Router contains the functions to check the http request and return the matching mock.

Jump to

Keyboard shortcuts

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