gonest
Request Pipeline

Overview & Execution Order

How Middleware, Guard, Interceptor and Filter compose

Every request flows through a fixed, proven order:

graph LR
    A[Global Middleware] --> B[Controller Middleware]
    B --> C[Guard]
    C --> D[Interceptor - before]
    D --> E[Handler]
    E --> F[Interceptor - after]
    F --> G[Response]
    H[Filter] -.wraps entire chain, catches panics.-> A
    H -.-> G
  • Global Middleware (Module.Use) always runs before Controller Middleware (Controller.Use).
  • Guard returning false short-circuits with an automatic 403 — the request never reaches an Interceptor or the Handler.
  • Interceptor wraps the Handler AOP-style: code before next(ctx) runs before the Handler, code after runs after.
  • Filter wraps the entire chain — it catches panics from anywhere inside it (Middleware, Guard, Interceptor, or Handler), not just the Handler.

Try it

A live "Try it" panel against a real gonest demo API lands here once the hosted demo is deployed (see .specs/features/docs-site/tasks.md T47-T49).

Next steps

On this page