resp

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package resp provides unified API response formatting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIError

func APIError(c echo.Context, err error) error

APIError returns an error response.

func ListDataResponse

func ListDataResponse(c echo.Context, list any, total int64) error

ListDataResponse returns a paginated list response.

func OneDataResponse

func OneDataResponse(c echo.Context, data any) error

OneDataResponse returns a single item response.

func OperateSuccess

func OperateSuccess(c echo.Context) error

OperateSuccess returns a success response for operations.

func SuccessJSON

func SuccessJSON(c echo.Context, data any) error

SuccessJSON returns a success response with custom data.

Types

type ListResponse

type ListResponse struct {
	List  any   `json:"list"`
	Total int64 `json:"total"`
}

ListResponse is the response structure for list endpoints.

type Response

type Response struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data any    `json:"data,omitempty"`
}

Response is the unified API response structure.

Jump to

Keyboard shortcuts

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