Documentation ¶
Index ¶
- Constants
- func CommJsonResponse(ctx *gin.Context, err errcode.AppError, data interface{}, errInfo ...string)
- func GetReqBodyToStruct(body []byte, appParams interface{}) (interface{}, error)
- func MiddlewareRsp(ctx *gin.Context, httpCode int, err errcode.AppError)
- func NewReqBody() interface{}
- func NewRspBody() interface{}
- func RegisterProDealFunc(funcs ...FuncCtx)
- func RegisterProtocol(protocolFunc func() ProtocolBase)
- type FuncCtx
- type ProtocolBase
- type RspStructBase
Constants ¶
View Source
const ( GinKeyReqBody = "_ReqBody" // 请求body数据 GinKeyRspBase = "_RspStructBase" // RspStructBase GinKeyBodyInterface = "_BodyInterface" // 请求参数中的 Interface )
Variables ¶
This section is empty.
Functions ¶
func CommJsonResponse ¶
通用协议:接口响应数据结构封装
func GetReqBodyToStruct ¶
通过body,格式化请求参数
func RegisterProtocol ¶
func RegisterProtocol(protocolFunc func() ProtocolBase)
注册协议的请求参数格式 和 返回参数格式
Types ¶
type ProtocolBase ¶
type ProtocolBase interface { NewReqBody() interface{} // New Req Body NewRspBody() interface{} // New Rsp Body // 通过body,格式化请求参数 GetReqBodyToStruct(body []byte, appParams interface{}) (interface{}, error) // 通过请求body,获取相应接口信息 GetRspByResBody(body []byte) (RspStructBase, error) // 通过请求body,获取请求结构体和相应接口信息 GetReqAndRspByResBody(body []byte, appParams interface{}) (RspStructBase, interface{}, error) }
协议类接口
type RspStructBase ¶
type RspStructBase interface { SetRspError(err errcode.AppError, strErr ...string) SetData(data interface{}) ToString() string // 请求&响应的Interface是一致的,所以可以通过响应体获取Interface GetBodyInterface() string }
response struct 相关的类接口
func GetReqAndRspByResBody ¶
func GetReqAndRspByResBody(body []byte, appParams interface{}) (RspStructBase, interface{}, error)
通过请求body,获取请求结构体和相应接口信息
Click to show internal directories.
Click to hide internal directories.