httpclient

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InjectHttp

func InjectHttp(r *http.Request) func(model.SpanContext)

InjectHttp 将context写入http请求头

func R

func R() *resty.Request

Types

type Option

type Option func(*ReqClient)

Option 配置函数

func Name

func Name(name string) Option

Name 服务名称配置

func Tracer

func Tracer(tracer *tracing.Tracer) Option

Tracer 链路跟踪配置

type ReqClient

type ReqClient struct {
	*tracing.Tracer
	ServiceName string
}

ReqClient http客户端

func New

func New(options ...Option) *ReqClient

New 构造函数

func (*ReqClient) RDelete

func (c *ReqClient) RDelete(url string, query map[string]string, ctx context.Context, v interface{}) error

RDelete delete请求

func (*ReqClient) RGet

func (c *ReqClient) RGet(url string, query map[string]string, ctx context.Context, v interface{}) error

RGet get请求

func (*ReqClient) RPost

func (c *ReqClient) RPost(url string, body interface{}, ctx context.Context, v interface{}) error

RPost post请求

func (*ReqClient) RPut

func (c *ReqClient) RPut(url string, body interface{}, ctx context.Context, v interface{}) error

RPut put请求

type Transport

type Transport struct {
	http.RoundTripper
	ServiceName string
}

Transport http客户端自定义传输类

func (*Transport) RoundTrip

func (tran *Transport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip 实现传输类必要方法

Jump to

Keyboard shortcuts

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