server

package
v2.3.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2018 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher struct {
	IP         string
	Port       int
	PortTLS    int
	ConfigTLS  string
	Resolver   Resolver
	Translator translate.MessageTranslator
	Processor  vars.Processor
	Scenario   scenario.Director
	Spier      match.Spier
	Mlog       chan definition.Match
}

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 definition.

func (Dispatcher) Start

func (di Dispatcher) Start()

Start initialize the HTTP mock server

type Resolver

type Resolver interface {
	Resolve(req *definition.Request) (*definition.Mock, *definition.MatchResult)
}

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

type Router

type Router struct {
	Mapping definition.Mapping
	Checker match.Checker
}

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

func NewRouter

func NewRouter(mapping definition.Mapping, checker match.Checker) *Router

NewRouter returns a pointer to new Router

func (*Router) Resolve

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