mock

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: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterMetrics added in v1.1.1

func RegisterMetrics() error

RegisterMetrics registers the prometheus metrics

Types

type Endpoint added in v0.0.13

type Endpoint struct {
	ID       string        `yaml:"id" json:"id"`
	Mock     *Mock         `yaml:"-" json:"mock" `
	Prio     int           `yaml:"prio" json:"prio"`
	Request  *MatchRequest `yaml:"request" json:"request"`
	Response *Response     `yaml:"response" json:"response"`
}

Endpoint configuration model for a mock endpoint

type MatchRequest

type MatchRequest struct {
	Host       string            `yaml:"host" json:"host"`
	Method     string            `yaml:"method" json:"method"`
	Path       string            `yaml:"path" json:"path"`
	Query      map[string]string `yaml:"query" json:"query"`
	Headers    map[string]string `yaml:"headers" json:"headers"`
	Body       string            `yaml:"body" json:"body"`
	BodyRegexp *regexp.Regexp    `yaml:"-" json:"-" `
}

MatchRequest configuration model for a http request

type Mock

type Mock struct {
	Name      string      `yaml:"name" json:"name"`
	Endpoints []*Endpoint `yaml:"endpoints" json:"-"`
}

Mock configuration model for a mock file

type RequestHandler added in v0.0.13

type RequestHandler struct {
	EpSearchNode *epSearchNode
	// contains filtered or unexported fields
}

RequestHandler implements an http server for mock endpoints

func NewRequestHandler added in v0.0.13

func NewRequestHandler(pathPrefix string, mockDir, mockFilepattern string, matchstore matches.Matchstore, funcMap template.FuncMap, 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

func (*RequestHandler) LoadFiles added in v0.0.13

func (r *RequestHandler) LoadFiles() error

LoadFiles reads the mockfiles from the mockDir and creates the datamodel for serving mock endpoints for http requests

type Response added in v0.0.13

type Response struct {
	Template     *template.Template `yaml:"-" json:"-"`
	StatusCode   string             `yaml:"statusCode" json:"statusCode"`
	Headers      string             `yaml:"headers" json:"headers"`
	Body         string             `yaml:"body" json:"body"`
	BodyFilename string             `yaml:"bodyFilename" json:"bodyFilename"`
}

Response configuration model for a http response

Jump to

Keyboard shortcuts

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