network

package
v0.0.0-...-790eabe Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: MulanPSL-2.0 Imports: 8 Imported by: 0

README

network

网络基础库。

  • Post:发送POST请求。
  • PostFile:发送POST文件请求。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Post

func Post[R any](
	baseUrl string,
	apiUrl string,
	headers map[string]interface{},
	requestBody interface{},
	hasResponse bool,
) (rsp R, err error)

发送内部请求(POST),并解析返回值。

baseUrl:基地址
apiUrl:URL后面的相对地址
headers:HTTP头信息,大小写敏感
requestBody:请求的Body
hasResponse:是否解析应答

func PostFile

func PostFile[R any](
	baseUrl string,
	apiUrl string,
	headers map[string]interface{},
	requestBodyKey string,
	requestBody interface{},
	fileKey string,
	fileName string,
	fileReader io.Reader,
	hasResponse bool,
) (rsp R, err error)

发送内部文件请求(POST),并解析返回值。

baseUrl:基地址
apiUrl:URL后面的相对地址
headers:HTTP头信息,大小写敏感
requestBodyKey:请求Body存放在表单的哪个键
requestBody:请求Body
fileKey:文件存放在表单的哪个键
fileName:文件名称
fileReader:文件读取句柄
hasResponse:是否解析应答

Types

This section is empty.

Jump to

Keyboard shortcuts

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