response

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorResponse added in v1.2.1

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

ErrorResponse maps the given error to an appropriate HTTP error response.

If the error is an *model.AppError, it extracts the error code and optional data. Otherwise, it falls back to mapping the error's message string through the error_code package.

@Failure 4xx/5xx {object} model.BaseResponse

func Response

func Response(c echo.Context, data any, err error) error

Response is a convenience helper that dispatches to SuccessResponseWithData or ErrorResponse based on whether err is nil.

Usage:

func GetUser(c echo.Context) error {
    user, err := service.GetUser(id)
    return response.Response(c, user, err)
}

func SuccessResponse added in v1.2.1

func SuccessResponse(c echo.Context) error

SuccessResponse returns HTTP 200 with a success response without data.

@Success 200 {object} model.BaseResponse

func SuccessResponseWithData added in v1.2.1

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

SuccessResponseWithData returns HTTP 200 with a typed success response.

@Success 200 {object} model.Response[T]

Types

This section is empty.

Jump to

Keyboard shortcuts

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