httpresp

package
v0.0.0-...-db77838 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package httpresp renders framework-specific HTTP error responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIError

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

APIError renders a project error as a JSON HTTP response.

func Created

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

Created renders a successful creation response envelope.

func DeletedIDs

func DeletedIDs(c *echo.Context, ids []int64) error

DeletedIDs renders a successful batch-delete response echoing the IDs.

func OK

func OK(c *echo.Context, data interface{}) error

OK renders a successful response envelope.

func Paginated

func Paginated(c *echo.Context, data interface{}, page, pageSize, total int) error

Paginated renders a successful paginated list response envelope.

func RequestID

func RequestID(c *echo.Context) string

RequestID returns the request ID used in HTTP error responses.

Types

type ErrorResponse

type ErrorResponse struct {
	Code      int    `json:"code"`
	Message   string `json:"message"`
	RequestID string `json:"request_id"`
	Timestamp int64  `json:"timestamp"`
}

ErrorResponse is the standard JSON error response for HTTP adapters.

type ListResponse

type ListResponse struct {
	Code      int         `json:"code"`
	Message   string      `json:"message"`
	Data      interface{} `json:"data"`
	Page      PageMeta    `json:"page"`
	RequestID string      `json:"request_id"`
	Timestamp int64       `json:"timestamp"`
}

ListResponse is the standard JSON list response for HTTP adapters.

type PageMeta

type PageMeta struct {
	Page     int  `json:"page"`
	PageSize int  `json:"page_size"`
	Total    int  `json:"total"`
	HasNext  bool `json:"has_next"`
}

PageMeta describes paginated list response metadata.

type Response

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

Response is the standard JSON success response for HTTP adapters.

Jump to

Keyboard shortcuts

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