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

feat(base): add redirect_slashes option to mount_to method #618

Merged
merged 1 commit into from
Jan 12, 2025

Conversation

noamsto
Copy link
Contributor

@noamsto noamsto commented Jan 9, 2025

Add optional redirect_slashes parameter to BaseAdmin.mount_to() and propagate it to SQLAlchemy Admin class. This allows users to control whether trailing slashes in URLs should be redirected, providing more flexibility in URL handling.

I'm working on a a litestar plugin to this awesome lib.
Inspired by https://github.com/peterschutt/sqladmin-litestar-plugin

Because of Starlette issue: encode/starlette#869
We have to turn of redirect_slashes. In all of the nested Starlette apps.
Because admin_app is created deep in the Base class, it's impossible to do it without hacking the lib.
This PR makes it convenient and is backward compatible.
If you have suggestions how to do it better, let me know!

Copy link
Owner

@jowilf jowilf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this. please update the mongoengine Admin class as well

Adds a `redirect_slashes` parameter to the `mount_to` method of the `BaseAdmin` class and its subclasses.
This allows users to control whether or not slashes are redirected when mounting the admin interface.

Signed-off-by: Noam Stolero <[email protected]>
Copy link

codecov bot commented Jan 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (2540c51) to head (49f0c37).
Report is 30 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #618   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           75        76    +1     
  Lines         5817      5906   +89     
=========================================
+ Hits          5817      5906   +89     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jowilf jowilf merged commit 2981324 into jowilf:main Jan 12, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants