web

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeXLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
)

Variables

View Source
var Router *gin.Engine

Functions

func BadRequestResponse

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

func CacheControl

func CacheControl(maxAge time.Duration) gin.HandlerFunc

CacheControl 缓存控制中间件

func Dir

Dir returns a http.FileSystem that can be used by http.FileServer(). It is used internally in Router.Static(). if listDirectory == true, then it works the same as http.Dir() otherwise it returns a filesystem that prevents http.FileServer() to list the directory files.

func ExcelFile

func ExcelFile(c *gin.Context, workbook *excelize.File, filename string) (err error)

func FailureResponse

func FailureResponse(c *gin.Context, code, msg string)

func FailureResponseWithArgs

func FailureResponseWithArgs(c *gin.Context, code, msg string, args any)

func HandleError

func HandleError(c *gin.Context, e error)

HandleError 统一使用 errcodes 包下面的错误码实现

func Init

func Init()

func InternalErrorResponse

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

func RequiredResponse

func RequiredResponse(c *gin.Context, name string)

func Run

func Run(ctx context.Context)

func StaticFS

func StaticFS(router gin.IRouter)

func SuccessResponse

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

Types

type APIResponse

type APIResponse struct {
	ErrorCode    string      `json:"code,omitempty"`
	ErrorMessage string      `json:"msg,omitempty"`
	ErrArgs      any         `json:"errArgs,omitempty"`
	Data         interface{} `json:"data,omitempty"`
	Success      bool        `json:"success,omitempty"` // 兼容旧版本
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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