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(core): new base middleware [RFC] #3996

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

provinzkraut
Copy link
Member

@provinzkraut provinzkraut commented Feb 13, 2025

Add a new base middleware class to facilitate easier configuration and middleware dispatching.

The new ASGIMiddleware features the same functionality as the AbstractMiddleware, but makes it easier to pass configuration directly to middleware classes without a separate configuration object, allowing to get rid of the DefineMiddleware pattern entirely.


If we are to add this, I propose we do so in v2, and migrate existing middlewares to this pattern in v3.

@github-actions github-actions bot added area/docs This PR involves changes to the documentation area/middleware This PR involves changes to the middleware area/private-api This PR involves changes to the privatized API size: small type/feat pr/internal labels Feb 13, 2025
Copy link

codecov bot commented Feb 13, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 98.29%. Comparing base (6768845) to head (1fd036d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
litestar/middleware/base.py 50.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3996      +/-   ##
==========================================
- Coverage   98.35%   98.29%   -0.06%     
==========================================
  Files         347      347              
  Lines       15783    15800      +17     
  Branches     1745     1746       +1     
==========================================
+ Hits        15523    15531       +8     
- Misses        124      133       +9     
  Partials      136      136              

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

Copy link
Contributor

@euri10 euri10 left a comment

Choose a reason for hiding this comment

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

lgtm
maybe add an example of transition from previous to new implementation ?

@provinzkraut
Copy link
Member Author

lgtm maybe add an example of transition from previous to new implementation ?

Yeah, I want to expand the docs in general a bit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs This PR involves changes to the documentation area/middleware This PR involves changes to the middleware area/private-api This PR involves changes to the privatized API pr/internal size: small type/feat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants