django-pgschemas icon indicating copy to clipboard operation
django-pgschemas copied to clipboard

Add support for tenancy routing via custom header

Open VaZark opened this issue 1 year ago • 4 comments

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.

VaZark avatar May 23 '23 06:05 VaZark

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?

lorinkoz avatar Jun 25 '23 09:06 lorinkoz

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 avatar Aug 11 '23 10:08 VaZark

@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.

lorinkoz avatar Aug 17 '23 09:08 lorinkoz

Actually, I've got plans to implement this with a better abstraction than the current code, using some ideas from another package. Stay tuned!

lorinkoz avatar Nov 14 '23 06:11 lorinkoz