requests

package
v1.1.64 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func BindResponseJSON

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

func GetRequestID

func GetRequestID(request *http.Request) string

func NewRequest

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

func PartFromData

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

func PartFromDiskFile

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

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 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 RandomRequestID

func RandomRequestID() 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