response

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

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

Error 使用 errno.Decode 方法,根据错误类型,尝试从 err 中提取业务错误码和错误信息.

func Success

func Success(c *gin.Context, data any, message string)

Success 将正确相应数据写入 HTTP 响应主体

Types

type Response

type Response struct {
	// Code 指定了业务错误码.
	Code int `json:"code"`

	// Message 包含了可以直接对外展示的错误信息.
	Message string `json:"message"`

	// Content 包含了可以直接对外展示的数据信息
	Content interface{} `json:"content"`
}

Response 定义了发生错误时的返回消息.

type TokenResponse

type TokenResponse struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int64  `json:"expires_in"`
}

TokenResponse JWT Token 响应结构

Jump to

Keyboard shortcuts

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