0Pricing
Learn Rust Coding · Lesson

Middleware

Tower layers.

What is middleware?

Middleware runs code before and after a handler, wrapping the request/response cycle. Use it for logging, auth, compression, and timeouts.

  • Axum builds on the tower ecosystem
  • Middleware is added as layers

The Service trait

Tower defines a Service: something that takes a request and asynchronously produces a response. Layers wrap one service in another.

All lessons in this course

  1. Axum Routing
  2. Extractors
  3. JSON and State
  4. Middleware
← Back to Learn Rust Coding