gin

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package gin provides adapters for using err-envelope with Gin framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Trace

func Trace() gin.HandlerFunc

Trace wires err-envelope trace ID middleware into Gin's middleware chain.

This generates or propagates trace IDs and makes them available via errenvelope.TraceIDFromRequest(c.Request).

Example:

r := gin.Default()
r.Use(Trace())
r.GET("/user", func(c *gin.Context) {
    traceID := errenvelope.TraceIDFromRequest(c.Request)
    // ...
})

func Write

func Write(c *gin.Context, err error)

Write sends a structured error response using err-envelope format.

This is a convenience wrapper that extracts c.Writer and c.Request to call errenvelope.Write.

Example:

r.GET("/user", func(c *gin.Context) {
    if userID == "" {
        Write(c, errenvelope.BadRequest("Missing user ID"))
        return
    }
    // ...
})

Types

This section is empty.

Jump to

Keyboard shortcuts

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