request

package
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2019 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// ContentTypeHeader value
	ContentTypeHeader = "Content-Type"
)

Variables

This section is empty.

Functions

func Do

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

Do send given method with given content to URL with optional headers supplied

func DoWithClient

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

DoWithClient execute request and return output with given client

func Form

func Form(ctx context.Context, method string, url string, data url.Values, headers http.Header) (*http.Request, error)

Form prepare a Form request from given params

func Get

func Get(ctx context.Context, url string, headers http.Header) (*http.Response, error)

Get send GET request to URL with optional headers supplied

func JSON

func JSON(ctx context.Context, method string, url string, body interface{}, headers http.Header) (*http.Request, error)

JSON prepare a JSON request from given params

func New

func New(ctx context.Context, method string, url string, body io.Reader, headers http.Header) (*http.Request, error)

New prepare a request from given params

func Post

func Post(ctx context.Context, url string, data url.Values, headers http.Header) (*http.Response, error)

Post send form via POST with urlencoded data

func PostJSON

func PostJSON(ctx context.Context, url string, data interface{}, headers http.Header) (*http.Response, error)

PostJSON send given method with given interface{} as JSON to URL with optional headers supplied

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)

func ReadContent

func ReadContent(body io.ReadCloser) (content []byte, err error)

ReadContent return content of given body

Types

This section is empty.

Jump to

Keyboard shortcuts

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