HTTP Lifecycle
HTTP Lifecycle
Request Lifecycle
Every HTTP request to a Lemmego application goes through a well-defined pipeline:
- Entry — The Go HTTP server receives the request
- HTTP Middleware — Global middleware runs first (recovery, logging, method override)
- Router — Zero-dependency router matches the request to a route
- App Middleware — Application-level middleware runs (CSRF, auth, etc.)
- Handler — The route handler processes the request and returns a response
- Response — The response is sent back to the client
Two Middleware Layers
Lemmego has two distinct middleware systems:
- HTTP Middleware (
func(http.Handler) http.Handler) — standardnet/httpmiddleware that wraps the entire router. Used for cross-cutting concerns like panic recovery and request logging. - App Middleware (
func(next Handler) Handler) — application-level middleware that operates on the LemmegoContext. Used for CSRF verification, authentication, and route-scoped logic.