django-pgschemas
django-pgschemas copied to clipboard
Add support for tenancy routing via custom header
Being able to define a custom header and using it for tenancy routing would make it a straightforward experience when django is used exclusively as a api backend.
The idea makes sense. Not so sure about providing this functionality as part of this package or rather encourage local implementation where required. Any ideas how we could make this generic enough so as to add it to pgschemas?
This is best added in a separate, optional middleware. I check if the URL is the API endpoint and then look for the header key. If it isn't the API endpoint, i just forward it to the next middleware. The current one has to be updated to check if the tenant has already been set, if yes -> forward it; else run the std logic
@VaZark Would you like to provide a PR adapted from your code? We could then work together on making the modifications required to integrate into this repo.
Actually, I've got plans to implement this with a better abstraction than the current code, using some ideas from another package. Stay tuned!