litestar-middleware

Installation
SKILL.md

Middleware

Execution Workflow

  1. Confirm the requirement is really middleware-worthy: broad ASGI wrapping, not route business logic.
  2. Prefer built-in config-based middleware first.
  3. Choose the right layer and ordering deliberately.
  4. Decide whether the concern belongs in middleware, lifecycle hooks, or route logic.
  5. For custom middleware, choose the simplest correct implementation style.
  6. Validate both success and exception-generated responses, plus exclusions and scope handling.

Core Rules

  • Keep middleware focused on one cross-cutting concern.
  • Prefer built-in middleware/config objects before creating custom implementations.
  • Treat middleware order as part of API behavior.
  • Keep middleware scope-aware for http, websocket, and lifespan as needed.
  • Use lifecycle hooks when the job is response-object mutation rather than ASGI message wrapping.
  • Keep middleware non-blocking and ASGI-compliant.
Related skills

More from alti3/litestar-skills

Installs
20
GitHub Stars
5
First Seen
Mar 2, 2026