Skip to content

Commit

Permalink
raise RuntimeError if middleware stack has already been created when …
Browse files Browse the repository at this point in the history
…initialiazing StacApi (#722)
  • Loading branch information
vincentsarago authored Jun 27, 2024
1 parent 4f410eb commit 6309713
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stac_fastapi/api/stac_fastapi/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ def __attrs_post_init__(self):
self.app.openapi = self.customize_openapi

# add middlewares
if self.middlewares and self.app.middleware_stack is not None:
raise RuntimeError("Cannot add middleware after an application has started")

for middleware in self.middlewares:
self.app.user_middleware.insert(0, middleware)

Expand Down

0 comments on commit 6309713

Please sign in to comment.