mock

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Header        = "header"
	Body          = "body"
	QueryString   = "query_string"
	Cookie        = "cookie"
	RouteParam    = "route_param"
	RequestNumber = "request_number"
)
View Source
const (
	Equal = "equal"
	Regex = "regex"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type And

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

func (*And) And

func (a *And) And(target, modifier, operator, value string) *And

And is used to combine multiple rules with AND operator

func (*And) Start

func (a *And) Start() (*httptest.Server, error)

Start starts the mock server

type Builder

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

func New

func New() *Builder

func (*Builder) Delete

func (b *Builder) Delete(url string) *Method

Delete make the DELETE request

func (*Builder) Get

func (b *Builder) Get(url string) *Method

Get make the GET request

func (*Builder) Option

func (b *Builder) Option(url string) *Method

Option make the OPTION request

func (*Builder) Post

func (b *Builder) Post(url string) *Method

Post make the POST request

func (*Builder) Put

func (b *Builder) Put(url string) *Method

Put make the PUT request

func (*Builder) Start

func (b *Builder) Start() (*httptest.Server, error)

Start starts the mock server

type Headers

type Headers map[string]string

type Method added in v0.1.0

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

func (*Method) Response added in v0.1.0

func (m *Method) Response(status int, body string, headers ...Headers) *Response

Response is used to define what will be responded to the request.

type Or

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

func (*Or) Or

func (o *Or) Or(target, modifier, operator, value string) *Or

Or is used to combine multiple rules with OR operator

func (*Or) Start

func (o *Or) Start() (*httptest.Server, error)

Start starts the mock server

type Response

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

func (*Response) Delay

func (r *Response) Delay(min, max int) *Response

Delay is a response delay in milliseconds

func (*Response) Start

func (r *Response) Start() (*httptest.Server, error)

Start starts the mock server

func (*Response) When

func (r *Response) When(target, modifier, operator, value string) *When

When is a response rule. It can be used to match a request.

func (*Response) WhenBodyEq added in v0.1.1

func (r *Response) WhenBodyEq(value string) *When

WhenBodyEq is a response rule. It can be used to match a request body with the given value.

func (*Response) WhenHeaderEq added in v0.1.1

func (r *Response) WhenHeaderEq(headerName, headerValue string) *When

WhenHeaderEq is a response rule. It can be used to match a request header with the given value.

func (*Response) WhenPathInBodyEq added in v0.1.1

func (r *Response) WhenPathInBodyEq(field string, value string) *When

WhenPathInBodyEq is a response rule. It can be used to match a child body with the given value.

func (*Response) WhenQueryStringEq added in v0.1.1

func (r *Response) WhenQueryStringEq(queryStringName, queryStringValue string) *When

WhenQueryStringEq is a response rule. It can be used to match a request query string with the given value.

func (*Response) WhenRouteParamEq added in v0.1.1

func (r *Response) WhenRouteParamEq(routeParamName, routeParamValue string) *When

WhenRouteParamEq is a response rule. It can be used to match a request route parameter with the given value.

type When

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

func (*When) And

func (w *When) And(target, modifier, operator, value string) *And

And is used to combine multiple rules with AND operator

func (*When) Or

func (w *When) Or(target, modifier, operator, value string) *Or

Or is used to combine multiple rules with OR operator

func (*When) Start

func (w *When) Start() (*httptest.Server, error)

Start starts the mock server

Jump to

Keyboard shortcuts

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