request

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = &http.Client{Timeout: time.Second * 10}

Functions

func AsyncDelete

func AsyncDelete(url string, headers map[string]string, body io.Reader, ch chan<- *Response, chErr chan<- error, chDone chan<- bool)

AsyncDelete sends DELETE requests concurrently

func AsyncGet

func AsyncGet(url string, headers map[string]string, ch chan<- *Response, chErr chan<- error, chDone chan<- bool)

AsyncGet sends GET requests concurrently

func AsyncPost

func AsyncPost(url string, headers map[string]string, body io.Reader, ch chan<- *Response, chErr chan<- error, chDone chan<- bool)

AsyncPost sends POST requests concurrently

func AsyncPut

func AsyncPut(url string, headers map[string]string, body io.Reader, ch chan<- *Response, chErr chan<- error, chDone chan<- bool)

AsyncPut sends PUT requests concurrently

func AsyncRequest

func AsyncRequest(method, url string, headers map[string]string, body io.Reader, ch chan<- *Response, chErr chan<- error, chDone chan<- bool)

AsyncRequest send requests concurrently

Types

type Request

type Request struct {
	Method  string
	URL     string
	Headers map[string]string
	Body    io.Reader
}

Request HTTP request

func NewRequest

func NewRequest(method, url string, headers map[string]string, body io.Reader) (req *Request)

NewRequest initalises new http request

func (*Request) Do

func (request *Request) Do(client *http.Client) (*Response, error)

Do initiates http request

type Response

type Response struct {
	Method     string
	StatusCode int
	URL        *url.URL
	Body       []byte
}

Response HTTP Response

func Delete

func Delete(url string, headers map[string]string, body io.Reader) (*Response, error)

Delete sends DELETE request

func Get

func Get(url string, headers map[string]string) (*Response, error)

Get sends GET request

func Post

func Post(url string, headers map[string]string, body io.Reader) (*Response, error)

Post sends POST request

func Put

func Put(url string, headers map[string]string, body io.Reader) (*Response, error)

Put sends PUT request

Jump to

Keyboard shortcuts

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