httputil

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package httputil provides HTTP utility functions for request and response handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleErrorGin

func HandleErrorGin(c *gin.Context, err error, logger *slog.Logger)

HandleErrorGin maps domain errors to HTTP status codes and returns a JSON response using Gin. This is an adapter for Gin's context that maintains the same error handling logic.

func HandleValidationErrorGin

func HandleValidationErrorGin(c *gin.Context, err error, logger *slog.Logger)

HandleValidationErrorGin writes a 400 Bad Request response for validation errors using Gin.

Types

type ErrorResponse

type ErrorResponse struct {
	Error   string `json:"error"`
	Message string `json:"message,omitempty"`
	Code    string `json:"code,omitempty"`
}

ErrorResponse represents a structured error response.

Jump to

Keyboard shortcuts

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