11
Middleware and Webhooks
In this chapter, we delve into the advanced and crucial aspects of middleware and webhooks in FastAPI. Middleware in FastAPI allows you to process requests and responses globally before they reach your route handlers and after they leave them. Webhooks, on the other hand, enable your FastAPI application to communicate with other services by sending real-time data updates. Both middleware and webhooks are essential for building robust, efficient, and scalable applications.
We will start by exploring how to create custom Asynchronous Server Gateway Interface (ASGI) middleware from scratch. This will give you a deep understanding of how middleware works at a fundamental level.
Next, we’ll develop middleware specifically ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access