ginx

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package ginx 提供一些 Gin 框架相关的工具

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetError

func GetError(c *gin.Context) (err any, ok bool)

GetError ...

func GetLang

func GetLang(c *gin.Context) i18n.Lang

GetLang ...

func GetLimit

func GetLimit(c *gin.Context) int

GetLimit 获取分页参数 Limit

func GetOffset

func GetOffset(c *gin.Context) int

GetOffset 获取分页参数 Offset

func GetPage

func GetPage(c *gin.Context) int

GetPage 获取分页参数 Page

func GetRequestID

func GetRequestID(c *gin.Context) string

GetRequestID ...

func GetTracer

func GetTracer(c *gin.Context) trace.Tracer

GetTracer 获取 tracer(the creator of Spans)

func GetUserID

func GetUserID(c *gin.Context) string

GetUserID ...

func SetErrResp

func SetErrResp(c *gin.Context, statusCode int, message string)

SetErrResp 为指定的 gin.Context 设置错误响应数据

func SetError

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

SetError ...

func SetLang

func SetLang(c *gin.Context, lang i18n.Lang)

SetLang ...

func SetRequestID

func SetRequestID(c *gin.Context, requestID string)

SetRequestID ...

func SetResp

func SetResp(c *gin.Context, statusCode int, data any)

SetResp 为指定的 gin.Context 设置成功响应数据(建议 200 <= statusCode < 300)

func SetTracer

func SetTracer(c *gin.Context, tracer trace.Tracer)

SetTracer ...

func SetUserID

func SetUserID(c *gin.Context, userID string)

SetUserID ...

Types

type PaginatedResp

type PaginatedResp struct {
	Count   int64 `json:"count"`
	Results any   `json:"results"`
}

PaginatedResp 分页响应数据体

func NewPaginatedRespData

func NewPaginatedRespData(count int64, results any) PaginatedResp

NewPaginatedRespData 创建分页响应数据体 注意:results 类型应该是 Slice / Array

type Response

type Response struct {
	Message   string `json:"message"`
	Data      any    `json:"data"`
	RequestID string `json:"requestID"`
}

Response 通用响应体

Jump to

Keyboard shortcuts

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