responses

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Created

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

Created responds with 201 and the data wrapped in a success envelope.

func Error

func Error(c *gin.Context, status int, message string)

Error responds with the given status code and an error message.

func Paginated

func Paginated(c *gin.Context, data interface{}, page, perPage int, total int64)

Paginated responds with 200, data, and pagination metadata.

func Success

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

Success responds with 200 and the data wrapped in a success envelope.

Types

type APIResponse

type APIResponse struct {
	Success bool        `json:"success"`
	Data    interface{} `json:"data,omitempty"`
	Error   string      `json:"error,omitempty"`
	Meta    *Meta       `json:"meta,omitempty"`
}

APIResponse is the standard JSON envelope for all API responses.

type Meta

type Meta struct {
	Page       int   `json:"page"`
	PerPage    int   `json:"per_page"`
	Total      int64 `json:"total"`
	TotalPages int   `json:"total_pages"`
}

Meta holds pagination metadata.

Jump to

Keyboard shortcuts

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