response

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package response provides HTTP response handling utilities including error handling, response building, and standardized response formats.

Package response provides HTTP response handling utilities including error handling, response building, and standardized response formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorResponse added in v0.1.5

func ErrorResponse(c echo.Context, statusCode int, message string) error

ErrorResponse sends an error response with a custom status code

func Success

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

Success sends a successful response with the given data

Types

type APIResponse added in v0.1.5

type APIResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message,omitempty"`
	Data    any    `json:"data,omitempty"`
}

APIResponse represents a standardized API response structure

type ErrorHandler added in v0.1.5

type ErrorHandler struct {
	// contains filtered or unexported fields
}

ErrorHandler provides unified error handling across the application

func NewErrorHandler added in v0.1.5

func NewErrorHandler(logger logging.Logger, sanitizer sanitization.ServiceInterface) *ErrorHandler

NewErrorHandler creates a new error handler instance

func (*ErrorHandler) HandleAuthError added in v0.1.5

func (h *ErrorHandler) HandleAuthError(err error, c echo.Context) error

HandleAuthError handles authentication errors

func (*ErrorHandler) HandleDomainError added in v0.1.5

func (h *ErrorHandler) HandleDomainError(err *domainerrors.DomainError, c echo.Context) error

HandleDomainError handles domain-specific errors

func (*ErrorHandler) HandleError added in v0.1.5

func (h *ErrorHandler) HandleError(_ error, c echo.Context, message string) error

HandleError handles generic errors

func (*ErrorHandler) HandleNotFoundError added in v0.1.5

func (h *ErrorHandler) HandleNotFoundError(resource string, c echo.Context) error

HandleNotFoundError handles not found errors

type ErrorHandlerInterface added in v0.1.5

type ErrorHandlerInterface interface {
	HandleError(err error, c echo.Context, message string) error
	HandleDomainError(err *domainerrors.DomainError, c echo.Context) error
	HandleAuthError(err error, c echo.Context) error
	HandleNotFoundError(resource string, c echo.Context) error
}

ErrorHandlerInterface defines the interface for error handling

Jump to

Keyboard shortcuts

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