mock

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package mock provides Mock filter.

Index

Constants

View Source
const (
	// Kind is the kind of Mock.
	Kind = "Mock"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MatchRule

type MatchRule struct {
	Path            string                               `json:"path,omitempty" jsonschema:"pattern=^/"`
	PathPrefix      string                               `json:"pathPrefix,omitempty" jsonschema:"pattern=^/"`
	Headers         map[string]*stringtool.StringMatcher `json:"headers,omitempty"`
	MatchAllHeaders bool                                 `json:"matchAllHeaders,omitempty"`
}

MatchRule is the rule to match a request

type Mock

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

Mock is filter Mock.

func (*Mock) Close

func (m *Mock) Close()

Close closes Mock.

func (*Mock) Handle

func (m *Mock) Handle(ctx *context.Context) string

Handle mocks Context.

func (*Mock) Inherit

func (m *Mock) Inherit(previousGeneration filters.Filter)

Inherit inherits previous generation of Mock.

func (*Mock) Init

func (m *Mock) Init()

Init initializes Mock.

func (*Mock) Kind

func (m *Mock) Kind() *filters.Kind

Kind returns the kind of Mock.

func (*Mock) Name

func (m *Mock) Name() string

Name returns the name of the Mock filter instance.

func (*Mock) Spec

func (m *Mock) Spec() filters.Spec

Spec returns the spec used by the Mock

func (*Mock) Status

func (m *Mock) Status() interface{}

Status returns status.

type Rule

type Rule struct {
	Match   MatchRule         `json:"match" jsonschema:"required"`
	Code    int               `json:"code" jsonschema:"required,format=httpcode"`
	Headers map[string]string `json:"headers,omitempty"`
	Body    string            `json:"body,omitempty"`
	Delay   string            `json:"delay,omitempty" jsonschema:"format=duration"`
	// contains filtered or unexported fields
}

Rule is the mock rule.

type Spec

type Spec struct {
	filters.BaseSpec `json:",inline"`

	Rules []*Rule `json:"rules"`
}

Spec describes the Mock.

Jump to

Keyboard shortcuts

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