Skip to content
This repository was archived by the owner on Sep 2, 2022. It is now read-only.

Commit b026cf5

Browse files
committed
Fix suggested FastAPI middleware installation order
Unlike e.g. Django (or Express) FastAPI executes the middlewares so that the first middleware that was added gets executed last and the last middleware gets executed as the first/outermost one.
1 parent a15a5f2 commit b026cf5

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Fix FastAPI middleware suggested installation order; it should ideally be the *last* one added.
13+
1014
## [1.5.0] - 2022-03-17
1115

1216
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ from fastapi import FastAPI
5454

5555
app = FastAPI()
5656

57-
# Ideally the first middleware you add.
57+
# Ideally the last middleware you add.
5858
app.add_middleware(ApilyticsMiddleware, api_key=os.getenv("APILYTICS_API_KEY"))
5959
```
6060

apilytics/fastapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ApilyticsMiddleware(starlette.middleware.base.BaseHTTPMiddleware):
1212
"""
1313
FastAPI middleware that sends API analytics data to Apilytics (https://apilytics.io).
1414
15-
This should ideally be the first middleware you add to your app.
15+
This should ideally be the last middleware you add to your app.
1616
1717
Examples:
1818
main.py::

0 commit comments

Comments
 (0)