response

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(c *app.RequestContext, message string)

BadRequest sends a 400 Bad Request response

func Created

func Created(c *app.RequestContext, data interface{})

Created sends a 201 Created response

func Error

func Error(c *app.RequestContext, statusCode int, message string)

Error sends an error response with a custom status code (kept for backward compatibility)

func InternalError

func InternalError(c *app.RequestContext, message string)

InternalError sends a 500 Internal Server Error response. 出于安全:原始 detail 只写入服务端日志,不回传客户端(避免泄露 SQL/DSN/表名/文件路径等内部信息)。

func NoContent

func NoContent(c *app.RequestContext)

NoContent sends a 204 No Content response

func NotFound

func NotFound(c *app.RequestContext, message string)

NotFound sends a 404 Not Found response

func Paginated

func Paginated(c *app.RequestContext, list interface{}, total int64, page, pageSize int)

Paginated sends a 200 OK response with pagination data

func Success

func Success(c *app.RequestContext, data interface{})

Success sends a 200 OK response

Types

type BatchResponse

type BatchResponse struct {
	Total   int      `json:"total"`
	Success int      `json:"success"`
	Failed  int      `json:"failed"`
	Errors  []string `json:"errors,omitempty"`
}

BatchResponse 批量操作响应

type PaginatedData

type PaginatedData struct {
	List       interface{} `json:"list"`
	Pagination Pagination  `json:"pagination"`
}

PaginatedData 分页数据

type Pagination

type Pagination struct {
	Page       int   `json:"page"`
	PageSize   int   `json:"page_size"`
	Total      int64 `json:"total"`
	TotalPages int   `json:"total_pages"`
}

Pagination 分页信息

type Response

type Response struct {
	Code      int         `json:"code"`
	Message   string      `json:"message"`
	Data      interface{} `json:"data"`
	Timestamp int64       `json:"timestamp"`
}

Response 统一响应格式

Jump to

Keyboard shortcuts

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