requests

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GET     = Method("GET")
	POST    = Method("POST")
	PUT     = Method("PUT")
	DELETE  = Method("DELETE")
	HEAD    = Method("HEAD")
	TRACE   = Method("TRACE")
	OPTIONS = Method("OPTIONS")
	CONNECT = Method("CONNECT")
)

Functions

func BindResponseJSON

func BindResponseJSON(response *http.Response, v interface{}) error

func NewRequest

func NewRequest(opts ...RequestOpt) (*http.Request, error)

func ReadResponseBody

func ReadResponseBody(response *http.Response) ([]byte, error)

Types

type Client

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

func NewClient

func NewClient(opts ...ClientOpt) *Client

func (*Client) Send

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

type ClientOpt

type ClientOpt = func(*clientConfig)

func MaxRetries

func MaxRetries(maxRetries int) ClientOpt

func RetryDelayFactor

func RetryDelayFactor(retryDelayFactor time.Duration) ClientOpt

func Timeout

func Timeout(timeout time.Duration) ClientOpt

type Part

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

func PartFromData

func PartFromData(fieldName, fileName string, data interface{}) *Part

func PartFromDiskFile

func PartFromDiskFile(fieldName, fileName, diskPath string) *Part

type RequestOpt

type RequestOpt = func(*requestConfig) error

func BasicAuth

func BasicAuth(username, password string) RequestOpt

func BearerToken

func BearerToken(token string) RequestOpt

func Body

func Body(body io.Reader) RequestOpt

func ContentType

func ContentType(contentType string) RequestOpt
func Cookie(cookie *http.Cookie) RequestOpt

func FormBody

func FormBody(form *url.Values) RequestOpt
func Header(key, value string) RequestOpt

func Host

func Host(host string) RequestOpt

func JSONBody

func JSONBody(body interface{}) RequestOpt

func Method

func Method(method string) RequestOpt

func MultipartForm

func MultipartForm(parts ...*Part) RequestOpt

func URL

func URL(url string) RequestOpt

func UserAgent

func UserAgent(userAgent string) RequestOpt

Jump to

Keyboard shortcuts

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