response

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//业务处理发生错误
	BusinessOccurredErrorCode int    = -4000000
	BusinessOccurredErrorMsg  string = "业务执行错误,请联系管理员处理"
	//服务器代码发生错误
	ServerOccurredErrorCode int    = -5000000
	ServerOccurredErrorMsg  string = "服务器内部发生代码执行错误,请联系开发者排查错误日志"
)

Variables

This section is empty.

Functions

func Bad

func Bad(c *gin.Context, errCode int, errMsg string)

标准失败响应

func Error

func Error(c *gin.Context, httpCode int)

func ErrorCode

func ErrorCode(c *gin.Context, httpCode int, errCode int)

func ErrorMessage

func ErrorMessage(c *gin.Context, httpCode int, dataCode int, msg string)

func Exception

func Exception(c *gin.Context, errCode int, errMessage string, msg string)

系统错误

func Fail

func Fail(c *gin.Context)

失败的业务逻辑

func FailCode

func FailCode(c *gin.Context, errCode int)

func FailError added in v0.0.3

func FailError(c *gin.Context, err *errors.Error)

func FailMessage

func FailMessage(c *gin.Context, errCode int, errMsg string)

func Forbidden

func Forbidden(c *gin.Context, msg string)

func NotAllowed added in v0.0.3

func NotAllowed(c *gin.Context, msg string)

func NotFound

func NotFound(c *gin.Context, msg string)

func OK

func OK(c *gin.Context, data interface{}) *gin.Context

语法糖函数封装 仅提交对象数据,不Abort()

func Page

func Page(context *gin.Context, total int64, list interface{})

func Response

func Response(c *gin.Context, httpCode, errCode int, data interface{}) *gin.Context

func ResponseWithJson

func ResponseWithJson(c *gin.Context, httpCode int, jsonStr string) *gin.Context

将json字符窜以标准json格式返回(例如,从redis读取json、格式的字符串,返回给浏览器json格式)

func Success

func Success(c *gin.Context, data interface{})

返回成功: OK() + Abort()

func SuccessWithHeader

func SuccessWithHeader(c *gin.Context, data interface{}, headers map[string]string)

func SystemError

func SystemError(c *gin.Context, err error)

系统执行代码错误

func SystemErrorCode

func SystemErrorCode(c *gin.Context, errCode int)

func SystemErrorMessage

func SystemErrorMessage(c *gin.Context, errCode int, msg string)

func SystemFail added in v0.0.3

func SystemFail(c *gin.Context, err error)

func SystemFailError added in v0.0.3

func SystemFailError(c *gin.Context, e *errors.Error, err error)

func Unauthorized

func Unauthorized(c *gin.Context, msg string)

func Unprocessable

func Unprocessable(c *gin.Context, msg string)

Types

type Gin

type Gin struct {
	C *gin.Context
}

func (*Gin) Response

func (g *Gin) Response(httpCode, errCode int, data interface{}) *gin.Context

Jump to

Keyboard shortcuts

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