rest

package
v0.0.0-...-36f27ca Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*resty.Client

	MetricOption MetricOption
	// contains filtered or unexported fields
}

func (Client) Delete

func (r Client) Delete(url string) *Request

func (Client) Get

func (r Client) Get(url string) *Request

func (Client) Patch

func (r Client) Patch(url string) *Request

func (Client) Post

func (r Client) Post(url string) *Request

func (Client) Put

func (r Client) Put(url string) *Request

type Interface

type Interface interface {
	Get(url string) *Request
	Put(url string) *Request
	Post(url string) *Request
	Delete(url string) *Request
	Patch(url string) *Request
	// contains filtered or unexported methods
}

func NewClient

func NewClient(options ...Option) Interface

type MetricOption

type MetricOption struct {
	Register prometheus.Registerer

	DurationBuckets []float64
}

type Option

type Option func(client *Client)

func AuthToken

func AuthToken(token string) Option

func BaseAuth

func BaseAuth(userName, pwd string) Option

func HostURL

func HostURL(url string) Option

func Retry

func Retry() Option

Retry 重试

func TLSFormCerts

func TLSFormCerts(certs ...tls.Certificate) Option

TLSFormCerts 证书

func TLSFormFilePath

func TLSFormFilePath(certFile, keyFile string) Option

type Request

type Request struct {
	*resty.Request
	// contains filtered or unexported fields
}

func (*Request) Body

func (r *Request) Body(body interface{}) *Request

func (*Request) DeleteHeader

func (r *Request) DeleteHeader(key string) *Request

func (*Request) Do

func (r *Request) Do() *Result

func (*Request) MetricDimension

func (r *Request) MetricDimension(value string) *Request

MetricDimension 添加指标维度

func (*Request) SetAuthToken

func (r *Request) SetAuthToken(token string) *Request

func (*Request) SetContext

func (r *Request) SetContext(ctx context.Context) *Request

func (*Request) SetError

func (r *Request) SetError(err *error) *Request

func (*Request) SetFile

func (r *Request) SetFile(fileName, filePath string) *Request

func (*Request) SetFiles

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

func (*Request) SetFormData

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

func (*Request) SetHeader

func (r *Request) SetHeader(name, key string) *Request

func (*Request) SetHeaders

func (r *Request) SetHeaders(headers map[string]string) *Request

func (*Request) SetHttpHeader

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

func (*Request) SetPathParam

func (r *Request) SetPathParam(paramName, paramValue string) *Request

SetPathParam request url params: /v1/users/{userId}/{subAccountId}/details

func (*Request) SetPathParams

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

SetPathParams request url params: /v1/users/{userId}/{subAccountId}/details

func (*Request) SetQueryParam

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

func (*Request) SetQueryParams

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

func (*Request) SetQueryParamsFromValues

func (r *Request) SetQueryParamsFromValues(params *url.URL) *Request

type Result

type Result struct {
	Body       []byte
	Err        error
	StatusCode int
	Header     http.Header
	Status     string

	Rid string
}

func (*Result) Into

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

type TLSClientConfig

type TLSClientConfig struct {
	// 跳过服务端证书验证
	InsecureSkipVerify bool

	// 服务端需要的证书
	CertFile string

	// 服务端需要的证书key
	KeyFile string

	// 根证书
	CAFile string

	// 证书decrypt密码
	Password string
}

Jump to

Keyboard shortcuts

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