client

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GetJson    = ApiProcessor{/* contains filtered or unexported fields */} // 返回类型: json -> *struct
	PostJson   = ApiProcessor{/* contains filtered or unexported fields */} // 请求类型 struct -> json  返回类型 json -> *struct
	PutJson    = ApiProcessor{/* contains filtered or unexported fields */} // 请求类型 struct -> json  返回类型 json -> *struct
	DelJson    = ApiProcessor{/* contains filtered or unexported fields */} // 返回类型: json -> *struct
	GetText    = ApiProcessor{/* contains filtered or unexported fields */} // 返回类型 []byte
	PostText   = ApiProcessor{/* contains filtered or unexported fields */} // 请求类型 []byte  返回类型 []byte
	PutText    = ApiProcessor{/* contains filtered or unexported fields */} // 请求类型 []byte  返回类型 []byte
	DeleteText = ApiProcessor{/* contains filtered or unexported fields */} // 返回类型 []byte
	PostForm   = ApiProcessor{/* contains filtered or unexported fields */} // 暂时不实现
	PostFile   = ApiProcessor{/* contains filtered or unexported fields */} // 暂时不实现
)

Functions

This section is empty.

Types

type ApiClient

type ApiClient[R any] struct {
	Url       string // 随机选一个
	Processor ApiProcessor
	Path      string
	Conf      Conf
	// contains filtered or unexported fields
}

常规请求定义

func (ApiClient[R]) Req

func (a ApiClient[R]) Req(req any, h map[string]string, qp ...string) (R, error)

执行网络请求

req: 请求方 body, res: 接收方 body(要求为指针类型), h: 需要的 http-header, qp: url中的参数,要求类似 "id=123" 样式,

func (ApiClient[R]) ReqWithCtx

func (a ApiClient[R]) ReqWithCtx(ctx context.Context, req any, h map[string]string, qp ...string) (R, error)

type ApiProcessor

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

type Conf

type Conf struct {
	CrtPath string
	KeyPath string
	Timeout int
}

Jump to

Keyboard shortcuts

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