-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Pass custom middlewares to the app #228
Labels
Comments
lorenzomassimiani
added
enhancement
New feature or request
help wanted
Extra attention is needed
labels
Aug 27, 2024
lorenzomassimiani
changed the title
Pass custom middlewares to the app
Feature: Pass custom middlewares to the app
Aug 27, 2024
sounds good. do you want to contribute? |
@lorenzomassimiani awesome idea. |
4 tasks
Temporary Workaround: server = LitServer(....)
server.app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
) |
Now that api = ls.examples.SimpleLitAPI()
server = ls.LitServer(api, middlewares=[(CORSMiddleware, {"allow_origins": ["*"], "allow_credentials": True, "allow_methods": ["*"], "allow_headers": ["*"]})]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
🚀 Feature
Add a parameter "middlewares" to the LitServer class that takes a list of fastapi middlewares that will be assigned to the self.app.
Motivation
It is useful to enrich the fastapi app with custom middlewares, for example for metrics updates. Similarly it can be done for exception handlers.
The text was updated successfully, but these errors were encountered: