Skip to content

Conversation

@JasperSui
Copy link

@JasperSui JasperSui commented Aug 26, 2023

Description

Since we can't process the request and response produced by django rest framework in an intuitive way currently,
so I try to introduce the middleware classes to django rest framework discussed in #7770.

If we can have the middleware classes for django rest framework only, then we don't have to implement the django middleware. The most important thing is we can process the request and response in django rest framework just like how middleware mechanism works in django, but without coupling the context between django and django rest freamwork.

@JasperSui
Copy link
Author

@auvipy I don't know how to fix the CI for Python 3.9, and I've seen this happened in other opened PRs too, I'll be happy to fix that if you can help me figure that out, thanks!

@@ -0,0 +1,26 @@
class BaseMiddleware:
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about extending django middleware mechanism instead?

Copy link
Author

Choose a reason for hiding this comment

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

You mean the whole flow of django middleware or just subclassing the django.utils.deprecation.MiddlewareMixin?

Copy link
Collaborator

Choose a reason for hiding this comment

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

DRF is an extension to django so we should be able to write custom middleware for DRF using django base middleware mechanism and custom it aligning with DRF's flow of reqquest response

@lovelydinosaur
Copy link
Contributor

Appreciate the input, tho... https://github.com/encode/django-rest-framework/blob/master/CONTRIBUTING.md

At this point in its lifespan we consider Django REST framework to be essentially feature-complete. We may accept pull requests that track the continued development of Django versions, but would prefer not to accept new features or code formatting changes.

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.

3 participants