Request Lifecycle
This page is a conceptual map. The line-by-line implementation lives under Annotated Source.
Deep dive:
- Annotated Source: Index
- Architecture: HTTP server, Proxy
HTTP request (typical)
- Listener accepts the request (server).
- Request metadata middleware ensures request/trace IDs.
- Logging middleware records request details and duration.
- Security headers middleware applies response headers.
- Router dispatches:
/healthand/readyz(internal handlers), or/v1/trade/*and/v1/task/*(proxy handlers), or- configured webhook paths (webhook handler).
Implementation:
- Server routes: Server
- Middleware chain: Middleware
- Proxy handler: Reverse proxy
- Webhooks: Webhook handler
- Health/readiness helpers: Health checker
WebSocket upgrade
When the request is a WebSocket upgrade:
- A concurrency limiter may reject requests at capacity.
- The gateway tracks upgraded connections and enforces idle timeouts by wrapping the hijacked
net.Conn.
Implementation:
- Limits + tracking: Server
- Streaming/protocol detection: Reverse proxy
- Metrics (connections): Protocol metrics, Metrics reference