request

package
v3.37.3 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 11 Imported by: 4 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(req *http.Request) (*http.Response, error)

Do send request with default client

func DoWithClient

func DoWithClient(client http.Client, req *http.Request) (*http.Response, error)

DoWithClient send request with given client

func ReadBodyRequest

func ReadBodyRequest(r *http.Request) ([]byte, error)

ReadBodyRequest return content of a body request (defined as a ReadCloser)

func ReadBodyResponse

func ReadBodyResponse(r *http.Response) ([]byte, error)

ReadBodyResponse return content of a body response (defined as a ReadCloser)

Types

type Request added in v3.1.0

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

Request describe a complete request

func New

func New() *Request

New create a new Request

func (*Request) BasicAuth added in v3.1.0

func (r *Request) BasicAuth(username, password string) *Request

BasicAuth add Basic Auth header

func (*Request) Build added in v3.1.0

func (r *Request) Build(ctx context.Context, payload io.Reader) (*http.Request, error)

Build create request for given context and payload

func (*Request) ContentForm added in v3.1.0

func (r *Request) ContentForm() *Request

ContentForm set Content-Type header to application/x-www-form-urlencoded

func (*Request) ContentJSON added in v3.1.0

func (r *Request) ContentJSON() *Request

ContentJSON set Content-Type header to application/json

func (*Request) ContentType added in v3.1.0

func (r *Request) ContentType(contentType string) *Request

ContentType set Content-Type header

func (*Request) Delete added in v3.1.0

func (r *Request) Delete(url string) *Request

Delete set DELETE to given url

func (*Request) Form added in v3.1.0

func (r *Request) Form(ctx context.Context, data url.Values) (*http.Response, error)

Form send request with given context and url.Values as payload

func (*Request) Get added in v3.1.0

func (r *Request) Get(url string) *Request

Get set GET to given url

func (*Request) Header added in v3.1.0

func (r *Request) Header(name, value string) *Request

Header add header to request

func (*Request) JSON added in v3.1.0

func (r *Request) JSON(ctx context.Context, body interface{}) (*http.Response, error)

JSON send request with given context and given interface as JSON payload

func (*Request) Method added in v3.1.0

func (r *Request) Method(method string) *Request

Method set method of Request

func (*Request) Patch added in v3.1.0

func (r *Request) Patch(url string) *Request

Patch set PATCH to given url

func (*Request) Post added in v3.1.0

func (r *Request) Post(url string) *Request

Post set POST to given url

func (*Request) Put added in v3.1.0

func (r *Request) Put(url string) *Request

Put set PUT to given url

func (*Request) Send added in v3.1.0

func (r *Request) Send(ctx context.Context, payload io.Reader) (*http.Response, error)

Send build request and send it with defined client

func (*Request) URL added in v3.1.0

func (r *Request) URL(url string) *Request

URL set URL of Request

func (*Request) WithClient added in v3.1.0

func (r *Request) WithClient(client http.Client) *Request

WithClient defines net/http client to use, instead of default one (30sec timeout and no redirect)

Jump to

Keyboard shortcuts

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