rest

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 15 Imported by: 0

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 ApplyProperties

func ApplyProperties(properties *ClientProperties) clientOpt

func BasicAuth

func BasicAuth(username, password string) requestOpt

func BearerToken

func BearerToken(token string) requestOpt

func BindResponseJSON

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

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 GetRequestID

func GetRequestID(request *http.Request) string
func Header(key, value string) requestOpt

func Host

func Host(host string) requestOpt

func JSONBody

func JSONBody(body interface{}) requestOpt

func MaxRetries

func MaxRetries(maxRetries int) clientOpt

func Method

func Method(method string) requestOpt

func MultipartForm

func MultipartForm(parts ...*part) requestOpt

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 RandomRequestID

func RandomRequestID() requestOpt

func ReadResponseBody

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

func RetryDelayFactor

func RetryDelayFactor(retryDelayFactor time.Duration) clientOpt

func Timeout

func Timeout(timeout time.Duration) clientOpt

func URL

func URL(format string, vars ...interface{}) requestOpt

func UserAgent

func UserAgent(userAgent string) requestOpt

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 ClientProperties

type ClientProperties struct {
	Timeout          int64 `json:"timeout" yaml:"timeout"`
	MaxRetries       int   `json:"maxRetries" yaml:"maxRetries"`
	RetryDelayFactor int64 `json:"retryDelayFactor" yaml:"retryDelayFactor"`
}

Jump to

Keyboard shortcuts

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