server

package
v3.1.6 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleCallback

func HandleCallback(cb mock.Callback) (*http.Response, error)

HandleCallback makes a callback required after a request

Types

type Dispatcher

type Dispatcher struct {
	IP         string
	Port       int
	PortTLS    int
	ConfigTLS  string
	Resolver   RequestResolver
	Translator mock.MessageTranslator
	Evaluator  vars.Evaluator
	Scenario   match.ScenearioStorer
	Spier      match.TransactionSpier
	Mlog       chan match.Transaction
}

Dispatcher is the mock http server

func (*Dispatcher) ServeHTTP

func (di *Dispatcher) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServerHTTP is the mock http server request handler. It uses the router to decide the matching mock and translator as adapter between the HTTP impelementation and the mock mock.

func (Dispatcher) Start

func (di Dispatcher) Start()

Start initialize the HTTP mock server

type RequestResolver

type RequestResolver interface {
	Resolve(req *mock.Request) (*mock.Definition, *match.Result)
}

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

type Router

type Router struct {
	Mapping config.Mapping
	Checker match.Matcher
}

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

func NewRouter

func NewRouter(mapping config.Mapping, checker match.Matcher) *Router

NewRouter returns a pointer to new Router

func (*Router) Resolve

func (rr *Router) Resolve(req *mock.Request) (*mock.Definition, *match.Result)

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

Jump to

Keyboard shortcuts

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