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

Allows classes as middleware #2923

Closed
wants to merge 1 commit into from
Closed

Allows classes as middleware #2923

wants to merge 1 commit into from

Conversation

nicolaipre
Copy link

Tiny fix that seemingly solves #2912

@nicolaipre nicolaipre requested a review from a team as a code owner February 29, 2024 21:22
@nicolaipre nicolaipre changed the title Solves #2912 Allows middleware as classes Feb 29, 2024
@nicolaipre nicolaipre changed the title Allows middleware as classes Allows classes as middleware Feb 29, 2024
Copy link

codecov bot commented Feb 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.997%. Comparing base (acb29c9) to head (f95e33e).

Additional details and impacted files
@@              Coverage Diff              @@
##              main     #2923       +/-   ##
=============================================
- Coverage   88.039%   87.997%   -0.042%     
=============================================
  Files           94        94               
  Lines         7433      7432        -1     
  Branches      1283      1283               
=============================================
- Hits          6544      6540        -4     
- Misses         622       624        +2     
- Partials       267       268        +1     

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

Copy link
Member

@ahopkins ahopkins left a comment

Choose a reason for hiding this comment

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

😎 Thanks
Can you add a unit test?

@nicolaipre
Copy link
Author

😎 Thanks Can you add a unit test?

Will do. Currently working on it but experienced some weird errors that I am not quite sure how to solve.

Some of the MiddlewareMixin Overloads seem to cause some confusion. My tests work when running locally, but fails with pytest for some reason.

I could push the test as it is right now if you would be willing to look at it to see if you are able to spot any obvious mistakes?

@nicolaipre
Copy link
Author

I have decided to close this PR as the change would introduce confusion since decorators are not intended to be used on Classes anyways.

The main goal was to allow users to register routes and middleware without using decorators as an alternative way of using Sanic, but this fix crashes with the way Sanic is intended to be used and is therefore no point adding in.

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