mockserver

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Default

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

func (*Default) GetHandler

func (e *Default) GetHandler(ctx context.Context) (h http.Handler, err error)

type DelayedResponseWriter

type DelayedResponseWriter struct {
	http.ResponseWriter
	Delay time.Duration
}

func (DelayedResponseWriter) Write

func (w DelayedResponseWriter) Write(b []byte) (int, error)

type MockServer

type MockServer interface {
	GetHandler(ctx context.Context) (h http.Handler, err error)
}

func New

func New(spec Specification) (m MockServer)

type Specification

type Specification struct {
	Name  string              `yaml:"name"`
	Port  int                 `yaml:"port"`
	Rules []SpecificationRule `yaml:"rules"`
}

type SpecificationRule

type SpecificationRule struct {
	Accept       string `yaml:"accept"`
	UseOrigin    string `yaml:"use_origin"`
	MockResponse struct {
		Status  int               `yaml:"status"`
		Body    string            `yaml:"body"`
		Headers map[string]string `yaml:"header"`
	} `yaml:"mock_response"`
	MockLatency SpecificationRuleLatency `yaml:"mock_latency"`
}

type SpecificationRuleLatency

type SpecificationRuleLatency struct {
	Mode    string `yaml:"mode"`
	HogMode string `yaml:"hog"`
	Value   int    `yaml:"value"`
	Swing   int    `yaml:"swing"`
}

Jump to

Keyboard shortcuts

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