Documentation
¶
Overview ¶
Package httputil provides HTTP utility functions for request and response handling.
Index ¶
- func HandleBadRequestGin(c *gin.Context, err error, logger *slog.Logger)
- func HandleErrorGin(c *gin.Context, err error, logger *slog.Logger)
- func HandleValidationErrorGin(c *gin.Context, err error, logger *slog.Logger)
- func ParsePagination(c *gin.Context) (offset, limit int, err error)
- type ErrorResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleBadRequestGin ¶ added in v0.20.0
HandleBadRequestGin writes a 400 Bad Request response for malformed JSON or parameters using Gin.
func HandleErrorGin ¶
HandleErrorGin maps domain errors to HTTP status codes and returns a JSON response using Gin.
func HandleValidationErrorGin ¶
HandleValidationErrorGin writes a 422 Unprocessable Entity response for validation errors using Gin.
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"` // Machine-readable error code
Message string `json:"message,omitempty"` // Human-readable error message
Code string `json:"code,omitempty"` // Additional error details (optional)
}
ErrorResponse represents a structured error response returned by the API.
Click to show internal directories.
Click to hide internal directories.