Documentation

Context

Use request context and helpers safely.

Overview

Context values can carry trace IDs, auth claims, and request-scoped state.

Example

Go

reqID, _ := c.Get("request_id")
return c.JSON(200, map[string]any{"requestId": reqID})

Best Practices

  • Use typed keys for shared context values.
  • Pass cancellation context to DB and queue calls.

Common Pitfalls

  • Storing large objects in request context.
  • Ignoring context cancellation in long operations.