result

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SUCCESS         = Error(200, "success")
	NeedRedirect    = Error(301, "need redirect")
	InvalidArgs     = Error(400, "invalid params")
	Unauthorized    = Error(401, "unauthorized")
	Forbidden       = Error(403, "forbidden")
	NotFound        = Error(404, "not found")
	Conflict        = Error(409, "entry exist")
	TooManyRequests = Error(429, "too many requests")
	ResultError     = Error(500, "response error")
	DatabaseError   = Error(598, "database error")
	CSRFDetected    = Error(599, "csrf attack detected")

	UserError  = Error(5001, "username or password error")
	CodeExpire = Error(5002, "verification expire")
	CodeError  = Error(5003, "verification error")
	UserExist  = Error(5004, "user Exist")
)

Functions

func Fail

func Fail(c *gin.Context, err Response)

func FailWithMsg

func FailWithMsg(c *gin.Context, err Response, msg string)

func Ok

func Ok(c *gin.Context)

func OkWithData

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

func OkWithMsg

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

func Result

func Result(c *gin.Context, code int, msg string, data interface{})

Types

type Response

type Response struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func Error

func Error(code int, msg string) Response

Jump to

Keyboard shortcuts

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