v2

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SimulationViewV1Schema = map[string]interface{}{
	"description": "Hoverfly simulation schema",
	"type":        "object",
	"required": []string{
		"data", "meta",
	},
	"additionalProperties": false,
	"properties": map[string]interface{}{
		"data": map[string]interface{}{
			"type": "object",
			"properties": map[string]interface{}{
				"pairs": map[string]interface{}{
					"type": "array",
					"items": map[string]interface{}{
						"$ref": "#/definitions/request-response-pair",
					},
				},
				"globalActions": map[string]interface{}{
					"type": "object",
					"properties": map[string]interface{}{
						"delays": map[string]interface{}{
							"type": "array",
							"items": map[string]interface{}{
								"$ref": "#/definitions/delay",
							},
						},
					},
				},
			},
		},
		"meta": map[string]interface{}{
			"$ref": "#/definitions/meta",
		},
	},
	"definitions": map[string]interface{}{
		"request-response-pair": requestResponsePairDefinition,
		"request":               requestV1Definition,
		"response":              responseDefinition,
		"headers":               headersDefinition,
		"delay":                 delaysDefinition,
		"meta":                  metaDefinition,
	},
}
View Source
var SimulationViewV2Schema = map[string]interface{}{
	"description": "Hoverfly simulation schema",
	"type":        "object",
	"required": []string{
		"data", "meta",
	},
	"additionalProperties": false,
	"properties": map[string]interface{}{
		"data": map[string]interface{}{
			"type": "object",
			"properties": map[string]interface{}{
				"pairs": map[string]interface{}{
					"type": "array",
					"items": map[string]interface{}{
						"$ref": "#/definitions/request-response-pair",
					},
				},
				"globalActions": map[string]interface{}{
					"type": "object",
					"properties": map[string]interface{}{
						"delays": map[string]interface{}{
							"type": "array",
							"items": map[string]interface{}{
								"$ref": "#/definitions/delay",
							},
						},
					},
				},
			},
		},
		"meta": map[string]interface{}{
			"$ref": "#/definitions/meta",
		},
	},
	"definitions": map[string]interface{}{
		"request-response-pair": requestResponsePairDefinition,
		"request":               requestV2Definition,
		"response":              responseDefinition,
		"field-matchers":        requestFieldMatchersV2Definition,
		"headers":               headersDefinition,
		"delay":                 delaysDefinition,
		"meta":                  metaDefinition,
	},
}

Functions

func ValidateSimulation added in v0.11.0

func ValidateSimulation(json, schema map[string]interface{}) error

Types

type CacheHandler added in v0.11.0

type CacheHandler struct {
	Hoverfly HoverflyCache
}

func (*CacheHandler) Delete added in v0.11.0

func (this *CacheHandler) Delete(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)

func (*CacheHandler) Get added in v0.11.0

func (this *CacheHandler) Get(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)

func (*CacheHandler) RegisterRoutes added in v0.11.0

func (this *CacheHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler)

type CacheView added in v0.11.0

type CacheView struct {
	Cache []CachedResponseView `json:"cache"`
}

type CachedResponseView added in v0.11.0

type CachedResponseView struct {
	Key          string                     `json:"key"`
	MatchingPair *RequestResponsePairViewV2 `json:"matchingPair,omitempty"`
	HeaderMatch  bool                       `json:"headerMatch"`
}

type DataViewV1 added in v0.11.0

type DataViewV1 struct {
	RequestResponsePairViewV1 []RequestResponsePairViewV1 `json:"pairs"`
	GlobalActions             GlobalActionsView           `json:"globalActions"`
}

type DataViewV2 added in v0.11.0

type DataViewV2 struct {
	RequestResponsePairs []RequestResponsePairViewV2 `json:"pairs"`
	GlobalActions        GlobalActionsView           `json:"globalActions"`
}

type DestinationView

type DestinationView struct {
	Destination string `json:"destination"`
}

type GlobalActionsView

type GlobalActionsView struct {
	Delays []v1.ResponseDelayView `json:"delays"`
}

type Hoverfly

type Hoverfly interface {
	GetDestination() string
	GetMiddleware() (string, string, string)
	GetMode() string
	GetStats() metrics.Stats
	GetVersion() string
	GetUpstreamProxy() string
}

type HoverflyCache added in v0.11.0

type HoverflyCache interface {
	GetCache() (CacheView, error)
	FlushCache() error
}

type HoverflyDestination

type HoverflyDestination interface {
	GetDestination() string
	SetDestination(string) error
}

type HoverflyDestinationHandler

type HoverflyDestinationHandler struct {
	Hoverfly HoverflyDestination
}

func (*HoverflyDestinationHandler) Get

func (*HoverflyDestinationHandler) Put

func (*HoverflyDestinationHandler) RegisterRoutes

func (this *HoverflyDestinationHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler)

type HoverflyHandler

type HoverflyHandler struct {
	Hoverfly Hoverfly
}

func (*HoverflyHandler) Get

func (this *HoverflyHandler) Get(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)

func (*HoverflyHandler) RegisterRoutes

func (this *HoverflyHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler)

type HoverflyLogs added in v0.11.0

type HoverflyLogs interface {
	GetLogsView() LogsView
	GetFilteredLogsView(int) LogsView
}

type HoverflyMiddleware

type HoverflyMiddleware interface {
	GetMiddleware() (string, string, string)
	SetMiddleware(string, string, string) error
}

type HoverflyMiddlewareHandler

type HoverflyMiddlewareHandler struct {
	Hoverfly HoverflyMiddleware
}

func (*HoverflyMiddlewareHandler) Get

func (*HoverflyMiddlewareHandler) Put

func (*HoverflyMiddlewareHandler) RegisterRoutes

func (this *HoverflyMiddlewareHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler)

type HoverflyMode

type HoverflyMode interface {
	GetMode() string
	SetModeWithArguments(ModeView) error
}

type HoverflyModeHandler

type HoverflyModeHandler struct {
	Hoverfly HoverflyMode
}

func (*HoverflyModeHandler) Get

func (*HoverflyModeHandler) Put

func (*HoverflyModeHandler) RegisterRoutes

func (this *HoverflyModeHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler)

type HoverflySimulation

type HoverflySimulation interface {
	GetSimulation() (SimulationViewV2, error)
	PutSimulation(SimulationViewV2) error
	DeleteSimulation()
}

type HoverflyUpstreamProxy added in v0.10.1

type HoverflyUpstreamProxy interface {
	GetUpstreamProxy() string
}

type HoverflyUpstreamProxyHandler added in v0.10.1

type HoverflyUpstreamProxyHandler struct {
	Hoverfly HoverflyUpstreamProxy
}

func (*HoverflyUpstreamProxyHandler) Get added in v0.10.1

func (*HoverflyUpstreamProxyHandler) RegisterRoutes added in v0.10.1

func (this *HoverflyUpstreamProxyHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler)

type HoverflyUsage

type HoverflyUsage interface {
	GetStats() metrics.Stats
}

type HoverflyUsageHandler

type HoverflyUsageHandler struct {
	Hoverfly HoverflyUsage
}

func (*HoverflyUsageHandler) Get

func (*HoverflyUsageHandler) RegisterRoutes

func (this *HoverflyUsageHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler)

type HoverflyVersion added in v0.10.1

type HoverflyVersion interface {
	GetVersion() string
}

type HoverflyVersionHandler added in v0.10.1

type HoverflyVersionHandler struct {
	Hoverfly HoverflyVersion
}

func (*HoverflyVersionHandler) Get added in v0.10.1

func (*HoverflyVersionHandler) RegisterRoutes added in v0.10.1

func (this *HoverflyVersionHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler)

type HoverflyView

type HoverflyView struct {
	DestinationView
	MiddlewareView `json:"middleware"`
	ModeView
	UsageView
	VersionView
	UpstreamProxyView
}

type LogsHandler added in v0.11.0

type LogsHandler struct {
	Hoverfly HoverflyLogs
}

func (*LogsHandler) Get added in v0.11.0

func (this *LogsHandler) Get(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)

func (*LogsHandler) GetWS added in v0.11.0

func (this *LogsHandler) GetWS(w http.ResponseWriter, r *http.Request)

func (*LogsHandler) RegisterRoutes added in v0.11.0

func (this *LogsHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler)

type LogsView added in v0.11.0

type LogsView struct {
	Logs []map[string]interface{} `json:"logs"`
}

type MetaView

type MetaView struct {
	SchemaVersion   string `json:"schemaVersion"`
	HoverflyVersion string `json:"hoverflyVersion"`
	TimeExported    string `json:"timeExported"`
}

func NewMetaView added in v0.11.0

func NewMetaView(version string) *MetaView

type MiddlewareView

type MiddlewareView struct {
	Binary string `json:"binary"`
	Script string `json:"script"`
	Remote string `json:"remote"`
}

type ModeArgumentsView added in v0.11.0

type ModeArgumentsView struct {
	Headers []string `json:"headersWhitelist,omitempty"`
}

type ModeView

type ModeView struct {
	Mode      string            `json:"mode"`
	Arguments ModeArgumentsView `json:"arguments,omitempty"`
}

type RequestDetailsViewV1 added in v0.11.0

type RequestDetailsViewV1 struct {
	RequestType *string             `json:"requestType"`
	Path        *string             `json:"path"`
	Method      *string             `json:"method"`
	Destination *string             `json:"destination"`
	Scheme      *string             `json:"scheme"`
	Query       *string             `json:"query"`
	Body        *string             `json:"body"`
	Headers     map[string][]string `json:"headers"`
}

RequestDetailsView is used when marshalling and unmarshalling RequestDetails

func (RequestDetailsViewV1) GetBody added in v0.11.0

func (this RequestDetailsViewV1) GetBody() *string

Gets Body - required for interfaces.Request

func (RequestDetailsViewV1) GetDestination added in v0.11.0

func (this RequestDetailsViewV1) GetDestination() *string

Gets Destination - required for interfaces.Request

func (RequestDetailsViewV1) GetHeaders added in v0.11.0

func (this RequestDetailsViewV1) GetHeaders() map[string][]string

Gets Headers - required for interfaces.Request

func (RequestDetailsViewV1) GetMethod added in v0.11.0

func (this RequestDetailsViewV1) GetMethod() *string

Gets Method - required for interfaces.Request

func (RequestDetailsViewV1) GetPath added in v0.11.0

func (this RequestDetailsViewV1) GetPath() *string

Gets Path - required for interfaces.Request

func (RequestDetailsViewV1) GetQuery added in v0.11.0

func (this RequestDetailsViewV1) GetQuery() *string

Gets Query - required for interfaces.Request

func (RequestDetailsViewV1) GetScheme added in v0.11.0

func (this RequestDetailsViewV1) GetScheme() *string

Gets Scheme - required for interfaces.Request

type RequestDetailsViewV2 added in v0.11.0

type RequestDetailsViewV2 struct {
	Path        *RequestFieldMatchersView `json:"path,omitempty"`
	Method      *RequestFieldMatchersView `json:"method,omitempty"`
	Destination *RequestFieldMatchersView `json:"destination,omitempty"`
	Scheme      *RequestFieldMatchersView `json:"scheme,omitempty"`
	Query       *RequestFieldMatchersView `json:"query,omitempty"`
	Body        *RequestFieldMatchersView `json:"body,omitempty"`
	Headers     map[string][]string       `json:"headers,omitempty"`
}

RequestDetailsView is used when marshalling and unmarshalling RequestDetails

type RequestFieldMatchersView added in v0.11.0

type RequestFieldMatchersView struct {
	ExactMatch    *string `json:"exactMatch,omitempty"`
	XmlMatch      *string `json:"xmlMatch,omitempty"`
	XpathMatch    *string `json:"xpathMatch,omitempty"`
	JsonMatch     *string `json:"jsonMatch,omitempty"`
	JsonPathMatch *string `json:"jsonPathMatch,omitempty"`
	RegexMatch    *string `json:"regexMatch,omitempty"`
	GlobMatch     *string `json:"globMatch,omitempty"`
}

type RequestResponsePairViewV1 added in v0.11.0

type RequestResponsePairViewV1 struct {
	Response ResponseDetailsView  `json:"response"`
	Request  RequestDetailsViewV1 `json:"request"`
}

func (RequestResponsePairViewV1) GetRequest added in v0.11.0

func (this RequestResponsePairViewV1) GetRequest() interfaces.Request

Gets Request - required for interfaces.RequestResponsePairView

func (RequestResponsePairViewV1) GetResponse added in v0.11.0

func (this RequestResponsePairViewV1) GetResponse() interfaces.Response

Gets Response - required for interfaces.RequestResponsePairView

type RequestResponsePairViewV2 added in v0.11.0

type RequestResponsePairViewV2 struct {
	Response ResponseDetailsView  `json:"response"`
	Request  RequestDetailsViewV2 `json:"request"`
}

func (RequestResponsePairViewV2) GetResponse added in v0.11.0

func (this RequestResponsePairViewV2) GetResponse() interfaces.Response

Gets Response - required for interfaces.RequestResponsePairView

type ResponseDetailsView

type ResponseDetailsView struct {
	Status      int                 `json:"status"`
	Body        string              `json:"body"`
	EncodedBody bool                `json:"encodedBody"`
	Headers     map[string][]string `json:"headers"`
}

ResponseDetailsView is used when marshalling and unmarshalling requests. This struct's Body may be Base64 encoded based on the EncodedBody field.

func (ResponseDetailsView) GetBody

func (this ResponseDetailsView) GetBody() string

Gets Body - required for interfaces.Response

func (ResponseDetailsView) GetEncodedBody

func (this ResponseDetailsView) GetEncodedBody() bool

Gets EncodedBody - required for interfaces.Response

func (ResponseDetailsView) GetHeaders

func (this ResponseDetailsView) GetHeaders() map[string][]string

Gets Headers - required for interfaces.Response

func (ResponseDetailsView) GetStatus

func (this ResponseDetailsView) GetStatus() int

Gets Status - required for interfaces.Response

type SimulationHandler

type SimulationHandler struct {
	Hoverfly HoverflySimulation
}

func (*SimulationHandler) Delete

func (this *SimulationHandler) Delete(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)

func (*SimulationHandler) Get

func (*SimulationHandler) GetSchema added in v0.11.0

func (this *SimulationHandler) GetSchema(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)

func (*SimulationHandler) Put

func (*SimulationHandler) RegisterRoutes

func (this *SimulationHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler)

type SimulationViewV1 added in v0.11.0

type SimulationViewV1 struct {
	DataViewV1 `json:"data"`
	MetaView   `json:"meta"`
}

func (SimulationViewV1) Upgrade added in v0.11.0

func (this SimulationViewV1) Upgrade() SimulationViewV2

type SimulationViewV2 added in v0.11.0

type SimulationViewV2 struct {
	DataViewV2 `json:"data"`
	MetaView   `json:"meta"`
}

func NewSimulationViewFromResponseBody added in v0.11.0

func NewSimulationViewFromResponseBody(responseBody []byte) (SimulationViewV2, error)

type UpstreamProxyView added in v0.10.1

type UpstreamProxyView struct {
	UpstreamProxy string `json:"upstream-proxy"`
}

type UsageView

type UsageView struct {
	Usage metrics.Stats `json:"usage"`
}

type VersionView added in v0.10.1

type VersionView struct {
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

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