Docs / Guides / Middleware · Health · Lifecycle

Platform 11–13 · Study guide

Middleware · Health · Lifecycle

Group HTTP middleware, expose health probes, and hook boot/request/shutdown events.

What you will learn
  • What middleware groups are for
  • Difference between /health and /health/ready
  • Which lifecycle hooks exist

1. Setup

Use the Application kernel so middleware, health, and lifecycle register together:

app = Application(".").with_framework_providers().create()

2. Middleware groups

MiddlewareManager lets you name stacks (for example web, api, auth) and attach them to routes. Keep cross-cutting concerns (logging, auth headers, CORS wrappers) out of every controller.

3. Health checks

EndpointMeaning
GET /healthProcess alive
GET /health/readyDependencies ready (when checks are registered)

4. Lifecycle hooks

  • boot — app starting
  • shutdown — app stopping
  • before / after — around a request
  • exception — centralized error observation

Use hooks for metrics, audit logs, or cleanup — not for primary business rules (those stay in services).