request

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder allows to create HTTP requests with a convenient API.

func NewTestBuilder

func NewTestBuilder(method, target string, body interface{}) Builder

NewTestBuilder returns a new Builder initialized with httptest.NewRequest

func (Builder) Request

func (b Builder) Request() *http.Request

Request returns the request

func (Builder) WithHeader

func (b Builder) WithHeader(key, value string) Builder

WithHeader sets the header key to value

type Reader

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

Reader wraps an http.Request and provides helper functions to read from it.

func NewReader

func NewReader(r *http.Request) Reader

NewReader returns a new Reader initialized with the given request

func (Reader) Bytes

func (r Reader) Bytes() ([]byte, error)

Bytes returns the request's body bytes

func (Reader) JSON

func (r Reader) JSON(v interface{}) error

JSON parses the request's body as JSON into v

func (Reader) MustBytes

func (r Reader) MustBytes() []byte

MustBytes returns the request's body bytes, or panics in case of error

func (Reader) MustJSON

func (r Reader) MustJSON(v interface{})

JSON parses the request's body as JSON into v, or panics in case of error

func (Reader) MustString

func (r Reader) MustString() string

MustString returns the request's body as a string, or panics in case of error

func (Reader) String

func (r Reader) String() (string, error)

String returns the request's body as a string

Jump to

Keyboard shortcuts

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