matches

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActualRequest

type ActualRequest struct {
	Method string              `json:"method" `
	URL    string              `json:"url" `
	Header map[string][]string `json:"header" `
	Host   string              `json:"host" `
}

ActualRequest datamodel for an incoming http request which is stored for a match or mismatch

type ActualResponse

type ActualResponse struct {
	StatusCode int                 `json:"statusCode"`
	Header     map[string][]string `json:"header"`
}

ActualResponse datamodel for an outgoing http response from a request which is stored for a match

type InMemoryMatchstore

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

InMemoryMatchstore implements a Matchstore using local memory

func (*InMemoryMatchstore) AddMatch

func (s *InMemoryMatchstore) AddMatch(endpointID string, match *Match) error

AddMatch registers a match for an endpoint

func (*InMemoryMatchstore) AddMismatch

func (s *InMemoryMatchstore) AddMismatch(mismatch *Mismatch) error

AddMismatch registers a mismatch

func (*InMemoryMatchstore) DeleteMatches

func (s *InMemoryMatchstore) DeleteMatches(endpointID string) error

DeleteMatches unregisters all matches for an endpoint

func (*InMemoryMatchstore) DeleteMismatches

func (s *InMemoryMatchstore) DeleteMismatches() error

DeleteMismatches unregisters all mismatches

func (*InMemoryMatchstore) GetMatches

func (s *InMemoryMatchstore) GetMatches(endpointID string) ([]*Match, error)

GetMatches returns all matches of http requests which hit an endpoint

func (*InMemoryMatchstore) GetMatchesCount

func (s *InMemoryMatchstore) GetMatchesCount(endpointID string) (uint64, error)

GetMatchesCount returns the count of all matches of http requests which hit an endpoint

func (*InMemoryMatchstore) GetMismatches

func (s *InMemoryMatchstore) GetMismatches() ([]*Mismatch, error)

GetMismatches returns all mismatches of http requests

func (*InMemoryMatchstore) GetMismatchesCount

func (s *InMemoryMatchstore) GetMismatchesCount() (uint64, error)

GetMismatchesCount returns count of all mismatches

func (*InMemoryMatchstore) Shutdown added in v1.3.0

func (s *InMemoryMatchstore) Shutdown() error

Shutdown is a no-op for InMemoryMatchstore

type Match

type Match struct {
	EndpointID     string          `json:"endpointId"`
	Timestamp      time.Time       `json:"timestamp"`
	ActualRequest  *ActualRequest  `json:"actualRequest"`
	ActualResponse *ActualResponse `json:"actualResponse"`
}

Match datamodel for a http request which hit an endpoint

type Matchstore

type Matchstore interface {
	GetMatches(endpointID string) ([]*Match, error)
	GetMatchesCount(endpointID string) (uint64, error)
	GetMismatches() ([]*Mismatch, error)
	AddMatch(endpointID string, match *Match) error
	AddMismatch(*Mismatch) error
	GetMismatchesCount() (uint64, error)
	DeleteMatches(endpointID string) error
	DeleteMismatches() error
	Shutdown() error
}

Matchstore is the interface for a storage which holds the http requests which matches mock endpoints.

func NewInMemoryMatchstore

func NewInMemoryMatchstore(size uint16) Matchstore

NewInMemoryMatchstore creates a new instance of InMemoryMatchstore

type Mismatch

type Mismatch struct {
	MismatchDetails string         `json:"MismatchDetails"`
	Timestamp       time.Time      `json:"timestamp"`
	ActualRequest   *ActualRequest `json:"actualRequest"`
}

Mismatch datamodel for a http request which missed an endpoint

type RequestHandler added in v0.0.13

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

RequestHandler implements an http API to access the Matchstore

func NewRequestHandler added in v0.0.13

func NewRequestHandler(pathPrefix string, matchStore Matchstore, logLevel string) *RequestHandler

NewRequestHandler creates an instance of RequestHandler

func (*RequestHandler) AddRoutes added in v0.0.13

func (r *RequestHandler) AddRoutes(router *mux.Router)

AddRoutes adds mux.Routes for the http API to a given mux.Router

Jump to

Keyboard shortcuts

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