response

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RespondError

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

RespondError writes a JSON error response with the given HTTP status code. The code parameter is a machine-readable slug (e.g. "not_found"), while message is a human-readable description of the problem.

func RespondErrorWithDetails

func RespondErrorWithDetails(c *gin.Context, status int, code string, message string, details any)

RespondErrorWithDetails writes a JSON error response that includes structured details, useful for validation errors where callers benefit from knowing exactly which fields failed.

Types

type APIError

type APIError struct {
	Error   string `json:"error"`
	Message string `json:"message"`
	Details any    `json:"details,omitempty"`
}

APIError is the standard JSON error response body returned by all API endpoints. It provides a machine-readable error code and a human-readable message, with an optional details field for structured validation errors.

Jump to

Keyboard shortcuts

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