Documentation
¶
Index ¶
- Variables
- func SetDefaultCode(code int64)
- func SetDefaultData(data interface{})
- func SetDefaultMsg(msg string)
- type Response
- type ServiceContext
- func (c *ServiceContext) BindValidator(obj interface{}) error
- func (c *ServiceContext) Error(err error)
- func (c *ServiceContext) ErrorCodeMsg(code int64, msg string)
- func (c *ServiceContext) Response(code int64, msg string, data interface{})
- func (c *ServiceContext) Return(err *code_err.CodeErr)
- func (c *ServiceContext) SetData(data interface{}) *code_err.CodeErr
- func (c *ServiceContext) Success(data interface{})
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrorBind = errors.New("missing required parameters")
)
Functions ¶
Types ¶
type Response ¶
type ServiceContext ¶
type ServiceContext struct {
*gin.Context
*code_err.Log
R Response
Ctx context.Context //gin.Context.Request.Context
}
func NewServiceContext ¶
func NewServiceContext(g *gin.Context) *ServiceContext
NewContext 初始化上下文包含context.Context
func (*ServiceContext) BindValidator ¶
func (c *ServiceContext) BindValidator(obj interface{}) error
BindValidator 参数绑定结构体,并且按照tag进行校验返回校验结果
func (*ServiceContext) ErrorCodeMsg ¶
func (c *ServiceContext) ErrorCodeMsg(code int64, msg string)
ErrorCodeMsg 直接指定code和msg
func (*ServiceContext) Response ¶
func (c *ServiceContext) Response(code int64, msg string, data interface{})
Response 直接指定code和msg和data
func (*ServiceContext) Return ¶
func (c *ServiceContext) Return(err *code_err.CodeErr)
func (*ServiceContext) SetData ¶
func (c *ServiceContext) SetData(data interface{}) *code_err.CodeErr
Success 返回正常数据
Click to show internal directories.
Click to hide internal directories.