client

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SchemeHTTP HTTP scheme prefix
	SchemeHTTP = "http://"
	// SchemeHTTPS HTTPS scheme prefix
	SchemeHTTPS = "https://"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Credential

type Credential map[string]interface{}

Credential credential to be filled in post body

type RESTClient

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

RESTClient client with metrics, ratelimit and

func NewRESTClient

func NewRESTClient() *RESTClient

NewRESTClient create rest client

func NewRESTClientWithTLS

func NewRESTClientWithTLS(conf *tls.Config) *RESTClient

NewRESTClientWithTLS create rest client with tls

func (*RESTClient) Delete

func (r *RESTClient) Delete() *Request

Delete create delete request

func (*RESTClient) Get

func (r *RESTClient) Get() *Request

Get create get request

func (*RESTClient) Head

func (r *RESTClient) Head() *Request

Head create head request

func (*RESTClient) Patch

func (r *RESTClient) Patch() *Request

Patch create patch request

func (*RESTClient) Post

func (r *RESTClient) Post() *Request

Post create post request

func (*RESTClient) Put

func (r *RESTClient) Put() *Request

Put create put request

func (*RESTClient) WithCredential

func (r *RESTClient) WithCredential(c Credential) *RESTClient

WithCredential set credential

func (*RESTClient) WithRateLimiter

func (r *RESTClient) WithRateLimiter(th throttle.RateLimiter) *RESTClient

WithRateLimiter set rate limiter

type Request

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

Request for http request

func (*Request) Body

func (r *Request) Body(body map[string]interface{}) *Request

Body set http body

func (*Request) Do

func (r *Request) Do() *Result

Do do http request

func (*Request) SubPathf

func (r *Request) SubPathf(subPath string, args ...interface{}) *Request

SubPathf set sub path

func (*Request) WithBasePath

func (r *Request) WithBasePath(basePath string) *Request

WithBasePath set base path

func (*Request) WithEndpoints

func (r *Request) WithEndpoints(endpoints []string) *Request

WithEndpoints set endpoints

func (*Request) WithHeaders

func (r *Request) WithHeaders(header http.Header) *Request

WithHeaders with http headers

func (*Request) WithParam

func (r *Request) WithParam(paramName, value string) *Request

WithParam add param

func (*Request) WithParams

func (r *Request) WithParams(params map[string]string) *Request

WithParams add params

func (*Request) WithParamsFromURL

func (r *Request) WithParamsFromURL(u *url.URL) *Request

WithParamsFromURL set params from url

func (*Request) WithTimeout

func (r *Request) WithTimeout(d time.Duration) *Request

WithTimeout with http timeout

func (*Request) WrapURL

func (r *Request) WrapURL() *url.URL

WrapURL use subPath args and params to fill url

type Result

type Result struct {
	Body       []byte
	Err        error
	StatusCode int
	Status     string
}

Result http result

func (*Result) Into

func (r *Result) Into(obj interface{}) error

Into decode result

Jump to

Keyboard shortcuts

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