adapters

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EchoErrorResponse

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

EchoErrorResponse sends an error response in Echo with logging.

func EchoSuccessResponse

func EchoSuccessResponse(c echo.Context, message string, data interface{}) error

EchoSuccessResponse sends a success response in Echo with logging.

func FiberErrorResponse

func FiberErrorResponse(c *fiber.Ctx, statusCode int, message, errorDetail string) error

FiberErrorResponse sends an error response in Fiber with logging.

func FiberSuccessResponse

func FiberSuccessResponse(c *fiber.Ctx, message string, data interface{}) error

FiberSuccessResponse sends a success response in Fiber with logging.

func GenerateErrorResponse

func GenerateErrorResponse(traceID, message, errorDetail string) core.StandardResponse

GenerateErrorResponse creates a standardized error response.

func GenerateSuccessResponse

func GenerateSuccessResponse(traceID, message string, data interface{}) core.StandardResponse

GenerateSuccessResponse creates a standardized success response.

func GenerateValidationErrorResponse

func GenerateValidationErrorResponse(traceID, message string, fieldErrors map[string]interface{}) core.StandardResponse

GenerateValidationErrorResponse creates a validation error response.

func GetOrGenerateTraceID

func GetOrGenerateTraceID(headers http.Header) string

GetOrGenerateTraceID retrieves a trace ID from headers or generates a new one.

func GinErrorResponse

func GinErrorResponse(c *gin.Context, statusCode int, message, errorDetail string)

GinErrorResponse sends an error response in Gin with logging.

func GinSuccessResponse

func GinSuccessResponse(c *gin.Context, message string, data interface{})

GinSuccessResponse sends a success response in Gin with logging.

func HTTPErrorResponse

func HTTPErrorResponse(w http.ResponseWriter, r *http.Request, statusCode int, message, errorDetail string)

HTTPErrorResponse sends an error response for net/http with logging.

func HTTPSuccessResponse

func HTTPSuccessResponse(w http.ResponseWriter, r *http.Request, message string, data interface{})

HTTPSuccessResponse sends a success response for net/http with logging.

func LogRequest

func LogRequest(method, path, traceID string, headers http.Header)

LogRequest logs incoming request details.

func LogResponse

func LogResponse(method, path, traceID string, statusCode int, duration time.Duration)

LogResponse logs outgoing response details.

func WriteJSONResponse

func WriteJSONResponse(w http.ResponseWriter, statusCode int, response core.StandardResponse)

WriteJSONResponse writes the response to the client.

Types

This section is empty.

Jump to

Keyboard shortcuts

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