Showing posts with label middlware. Show all posts
Showing posts with label middlware. Show all posts

Monday, May 13, 2024

FastAPI middleware performance

 As per the FastAPI docs, the way to create and add custom middlewares is


@app.middleware("http")
async def add_my_middlware(request: Request, call_next):
response = await call_next(request)
return response

Seems simple enough. Before the await, you can do something with the request. After the await, you can do something with the response.

But if you run benchmark, you will find something very surprising.

Why Your New External Drive is Breaking Your macOS Builds

Picture this: you're running dangerously low on disk space, so you invest in a brand new external drive. Time to migrate your developmen...