basethird

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 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 HttpThird

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

封装 http 接口的基础类

func (*HttpThird) Delete

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

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.0

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

func (*HttpThird) Options added in v1.2.9

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

func (*HttpThird) Patch added in v1.2.9

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 added in v1.2.10

func (a *HttpThird) SetMaxConnsPerHost(num int)

func (*HttpThird) SetMaxIdleConnsPerHost added in v1.2.10

func (a *HttpThird) SetMaxIdleConnsPerHost(num int)

func (*HttpThird) SetTLSClientConfig added in v1.2.2

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

func (*HttpThird) SetTLSInsecure added in v1.3.0

func (a *HttpThird) SetTLSInsecure()

type PostFile

type PostFile string

func (PostFile) Value added in v1.2.2

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

type Response added in v1.2.2

type Response struct {
	*grequests.Response
}

func (*Response) JSON added in v1.2.2

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

func (*Response) String added in v1.2.2

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

func (*Response) ToJSON added in v1.2.2

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.1

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

func (*RpcThird) AddUnaryClientInterceptor added in v1.4.1

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

func (*RpcThird) DisableDefaultStreamInterceptor added in v1.4.1

func (a *RpcThird) DisableDefaultStreamInterceptor()

func (*RpcThird) DisableDefaultUnaryInterceptor added in v1.4.1

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.0

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

func (*RpcThird) SetLogInfoFlag added in v1.2.5

func (a *RpcThird) SetLogInfoFlag(on bool)

设置是否要关闭 info 日志

type StreamClientInterceptor added in v1.2.7

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

type UnaryClientInterceptor added in v1.2.7

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