basethird

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2020 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Caller added in v1.6.0

type Caller func(method, uri string, ro *grequests.RequestOptions) (resp *Response, err error)

type HttpInterceptor added in v1.6.0

type HttpInterceptor func(method, uri string, ro *grequests.RequestOptions, call Caller) (*Response, error)

type HttpThird

type HttpThird struct {
	Address          string
	Hostname         string
	ConnectTimeout   int
	ReadWriteTimeout int
	SslOn            bool
	CertFile         string
	// contains filtered or unexported fields
}

封装 http 接口的基础类

func (*HttpThird) AddInterceptor added in v1.6.0

func (a *HttpThird) AddInterceptor(hi HttpInterceptor)

func (*HttpThird) Delete

func (a *HttpThird) Delete(api string, params map[string]interface{}, opts ...*grequests.RequestOptions) (*Response, error)

func (*HttpThird) DisableDefaultInterceptor added in v1.6.0

func (a *HttpThird) DisableDefaultInterceptor()

func (*HttpThird) Get

func (a *HttpThird) Get(api string, params map[string]interface{}, opts ...*grequests.RequestOptions) (*Response, error)

func (*HttpThird) Head

func (a *HttpThird) Head(api string, opts ...*grequests.RequestOptions) (*Response, error)

func (*HttpThird) InitConfig added in v1.3.1

func (a *HttpThird) InitConfig(configSection string) error

func (*HttpThird) Options

func (a *HttpThird) Options(api string, opts ...*grequests.RequestOptions) (*Response, error)

func (*HttpThird) Patch

func (a *HttpThird) Patch(api string, params map[string]interface{}, opts ...*grequests.RequestOptions) (*Response, error)

func (*HttpThird) Post

func (a *HttpThird) Post(api string, params map[string]interface{}, opts ...*grequests.RequestOptions) (*Response, error)

func (*HttpThird) Put

func (a *HttpThird) Put(api string, params map[string]interface{}, opts ...*grequests.RequestOptions) (*Response, error)

func (*HttpThird) SetBaseAuth

func (a *HttpThird) SetBaseAuth(username, password string)

func (*HttpThird) SetHeader

func (a *HttpThird) SetHeader(headers map[string]string)

func (*HttpThird) SetLogInfoFlag

func (a *HttpThird) SetLogInfoFlag(on bool)

设置是否要关闭 info 日志

func (*HttpThird) SetMaxConnsPerHost

func (a *HttpThird) SetMaxConnsPerHost(num int)

func (*HttpThird) SetMaxIdleConnsPerHost

func (a *HttpThird) SetMaxIdleConnsPerHost(num int)

func (*HttpThird) SetTLSClientConfig

func (a *HttpThird) SetTLSClientConfig(cfg *tls.Config)

func (*HttpThird) SetTLSInsecure added in v1.3.1

func (a *HttpThird) SetTLSInsecure()

type PostFile

type PostFile string

func (PostFile) Value

func (p PostFile) Value(name string) (f grequests.FileUpload, e error)

type Response

type Response struct {
	*grequests.Response
}

func ErrResponse added in v1.6.0

func ErrResponse(err error) *Response

func (*Response) JSON

func (r *Response) JSON(v interface{}) error

func (*Response) String

func (r *Response) String() (string, error)

func (*Response) ToJSON

func (r *Response) ToJSON(v interface{}) error

rewrite ToJSON then you can use ToJSON many times

type RpcThird

type RpcThird struct {
	sync.Mutex
	Address          string
	Timeout          int
	MaxRecvMsgsizeMb int
	MaxSendMsgsizeMb int
	SslOn            bool
	CertFile         string
	Hostname         string
	// contains filtered or unexported fields
}

封装 rpc 的基础类

func (*RpcThird) AddStreamClientInterceptor added in v1.4.10

func (a *RpcThird) AddStreamClientInterceptor(sci grpc.StreamClientInterceptor)

func (*RpcThird) AddUnaryClientInterceptor added in v1.4.10

func (a *RpcThird) AddUnaryClientInterceptor(uci grpc.UnaryClientInterceptor)

func (*RpcThird) DisableDefaultStreamInterceptor added in v1.4.10

func (a *RpcThird) DisableDefaultStreamInterceptor()

func (*RpcThird) DisableDefaultUnaryInterceptor added in v1.4.10

func (a *RpcThird) DisableDefaultUnaryInterceptor()

func (*RpcThird) GetConn

func (a *RpcThird) GetConn() (*grpc.ClientConn, error)

func (*RpcThird) GetCtx

func (a *RpcThird) GetCtx() (context.Context, context.CancelFunc)

func (*RpcThird) InitConfig added in v1.3.1

func (a *RpcThird) InitConfig(configSection string) error

func (*RpcThird) SetLogInfoFlag

func (a *RpcThird) SetLogInfoFlag(on bool)

设置是否要关闭 info 日志

type StreamClientInterceptor

type StreamClientInterceptor func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, opts ...grpc.CallOption) error

type UnaryClientInterceptor

type UnaryClientInterceptor func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, opts ...grpc.CallOption) error

Jump to

Keyboard shortcuts

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