Help us shape the future of Go! Take the 2026 Go Developer Survey

response

package
v1.8.23 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: GPL-3.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NoResponse

func NoResponse(_ *api.Context, _ int, _ any, _ error)

NoResponse 零值占位响应函数

func SendIDResponse

func SendIDResponse(c *api.Context, statusCode int, id string, err error)

SendIDResponse 发送ID响应的函数 参数: - c: 上下文 - statusCode: HTTP状态码 - id: 发送的id - err: 错误 返回值: 无

func SendInfoResponse

func SendInfoResponse[T any](c *api.Context, statusCode int, info T, err error)

SendInfoResponse 发送Info响应的函数 参数: - c: 上下文 - statusCode: HTTP状态码 - info: 发送的Info - err: 错误 返回值: 无

func SendInfosResponse

func SendInfosResponse[T any](c *api.Context, statusCode int, data InfosData[T], err error)

SendInfosResponse 发送Infos响应的函数 参数: - c: 上下文 - statusCode: HTTP状态码 - data: InfosData[T]结构,T是包含的Info类型 - err: 错误 返回值: 无

func SendMapResponse

func SendMapResponse(c *api.Context, statusCode int, data map[string]any, err error)

SendMapResponse 发送map响应的函数(实际响应的是Json) 参数: - c: 上下文 - statusCode: HTTP状态码 - data: map响应数据 - err: 错误 返回值: 无

func SendMsgResponse

func SendMsgResponse(c *api.Context, statusCode int, _ any, err error)

SendMsgResponse 发送MsgResponse的响应函数 参数: - c: 上下文 - statusCode: HTTP状态码 - data: 无效 - err: 错误 返回值: 无

func SendString

func SendString(c *api.Context, statusCode int, data string, err error)

SendString 发送字符串响应的函数 参数: - c: 上下文 - statusCode: HTTP状态码 - data: 字符串响应数据 - err: 错误 返回值: 无

func SendWXOrderResponse

func SendWXOrderResponse(c *api.Context, statusCode int, _ any, err error)

SendWXOrderResponse 微信订单响应函数 参数: - c: 上下文 - statusCode: HTTP状态码 - data: 无效 - err: 错误 返回值: 无

func StructToMap

func StructToMap(originStruct any) map[string]any

StructToMap 将结构转换为map的函数(用于作为map响应函数的发送数据) 参数: - originStruct: 原始结构 返回值: - 转换为的map

func WriteBytes

func WriteBytes(c *api.Context, statusCode int, bytes []byte, err error)

WriteBytes 发送字节响应的函数 参数: - c: 上下文 - statusCode: HTTP状态码 - data: 字节响应数据 - err: 错误 返回值: 无

Types

type IDResponse

type IDResponse struct {
	MsgResponse
	ID string `json:"id"`
}

IDResponse 响应ID的响应结构

type InfoResponse

type InfoResponse[T any] struct {
	MsgResponse
	Info T `json:"info"`
}

InfoResponse 响应Info的响应结构

type InfosData

type InfosData[T any] struct {
	Infos      []T   `json:"infos"`
	TotalCount int64 `json:"totalCount"`
	PageNo     int   `json:"pageNo"`
}

InfosData Infos响应的数据结构 类型参数: - T: Info结构类型

type InfosResponse

type InfosResponse[T any] struct {
	MsgResponse
	InfosData[T]
}

InfosResponse 响应Infos的响应结构

type MsgResponse

type MsgResponse struct {
	Success bool   `json:"success"`
	ErrCode int    `json:"errCode"`
	Msg     string `json:"msg"`
}

MsgResponse 响应头

type SendResponseFunc

type SendResponseFunc[O any] func(c *api.Context, statusCode int, data O, err error)

SendResponseFunc 发送响应函数

type WXOrderResponse

type WXOrderResponse struct {
	ReturnCode string `xml:"return_code"`
	ReturnMsg  string `xml:"return_msg"`
}

WXOrderResponse 微信订单响应结构

Jump to

Keyboard shortcuts

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