webmock

package
v0.0.0-...-bc6c5c1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unmarshal

func Unmarshal(t *testing.T, resp *http.Response, v interface{})

Types

type Client

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

func New

func New(opts ...Option) *Client

func (*Client) Cookie

func (c *Client) Cookie(name string) (string, bool)

func (*Client) Delete

func (c *Client) Delete(path string, values url.Values) (*http.Response, error)

func (*Client) Do

func (c *Client) Do(method, path string, values url.Values, body interface{}, opts ...func(r *http.Request)) (*http.Response, error)

func (*Client) Get

func (c *Client) Get(path string, values url.Values) (*http.Response, error)

func (*Client) Patch

func (c *Client) Patch(path string, values url.Values, body interface{}) (*http.Response, error)

func (*Client) Post

func (c *Client) Post(path string, values url.Values, body interface{}) (*http.Response, error)

func (*Client) Put

func (c *Client) Put(path string, values url.Values, body interface{}) (*http.Response, error)

func (*Client) Upload

func (c *Client) Upload(path string, values url.Values, r io.Reader, field, filename, contentType string) (*http.Response, error)

type Context

type Context interface {
	web.Context
	Recorder() *httptest.ResponseRecorder
}

func NewContext

func NewContext(opts ...ContextOption) Context

type ContextOption

type ContextOption func(m *mock)

func WithBodyString

func WithBodyString(content string) ContextOption

func WithForm

func WithForm(key, value string) ContextOption

func WithQuery

func WithQuery(key, value string) ContextOption

func WithRequest

func WithRequest(req *http.Request) ContextOption

func WithRoute

func WithRoute(key, value string) ContextOption

func WithValue

func WithValue(key string, value interface{}) ContextOption

type Option

type Option func(*Client)

func AuthFunc

func AuthFunc(authFunc func(*http.Request) error) Option

AuthFunc allows for an arbitrary authentication function

func BasicAuth

func BasicAuth(username, password string) Option

BasicAuth provides basic auth

func Codebase

func Codebase(codebase string) Option

Codebase allows one to specify a remote codebase (defaults to http://localhost)

func Endpoints

func Endpoints(endpoints ...*swagger.Endpoint) Option

Endpoint constructs a client directly from a swagger endpoint

func Filters

func Filters(filters ...web.Filter) Option

func Handler

func Handler(h http.Handler) Option

func HandlerFunc

func HandlerFunc(h web.HandlerFunc) Option

func Observer

func Observer(fn func(code int, method, endpoint string, elapsed time.Duration)) Option

func Output

func Output(w io.Writer) Option

Output enables debug output to be written to the specified writer

Jump to

Keyboard shortcuts

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