Skip to content
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

Reloading additional external pages? #30

Open
florimondmanca opened this issue Nov 13, 2022 · 0 comments
Open

Reloading additional external pages? #30

florimondmanca opened this issue Nov 13, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@florimondmanca
Copy link
Owner

florimondmanca commented Nov 13, 2022

Prompted by Kludex/uvicorn-extensions#15 (comment)

Problem description

Currently, arel can be used by injecting a {{ script }} in the user's app HTML.

But this is not workable on HTML the user can't control.

For example, the user may want their FastAPI docs page to reload when their Uvicorn server restarts, as the OpenAPI schema may have changed due to

On the other hand, it's possible they wouldn't want that. Maybe they're busy testing things in the Swagger UI and, while they're doing edits in the their Python source code, they may not want to lose what they've done in the UI (e.g. authentication credentials).

How should we address these use cases?

Suggested solution

TODO

Possible alternatives

  • Replace the manual {{ script }} thing with automatic injection on HTML pages.
    • This could be done by allowing users to register an ASGI middleware that detects HTML responses, and injects the script before the </body> closing tag. When running in DEBUG mode, users would turn this behavior off by not including the middleware.
    • This is somewhat similar to what django-debug-toolbar or fastapi-debug-toolbar do to inject their client-side toolbar JS on all pages -- including Swagger UI for fastapi-debug-toolbar (since that's an HTML page as well).
@florimondmanca florimondmanca added the enhancement New feature or request label Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant