revsys / django-health-check

a pluggable app that runs a full check on the deployment, using a number of plugins to check e.g. database, queue server, celery processes, etc.

Home Page:https://readthedocs.org/projects/django-health-check/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Access to Django request from within the plugin

db4y opened this issue · comments

commented

Hi

I'm writing a custom check and I would need some informations contained in Django's request object in my check. I could not find a way to access the request nor to pass it to the plugin.

Is it possible to access the request from the plugin?

Thank you.

Hi 👋

I'm afraid it's not possible because CheckMixin that is subclassed in MainView doesn't pass the request object down to plugins run_check calls.
So the only way is to rewrite this package flow or (personally I dislike this solution) use some middleware to set currently handled request to some global variable

commented

Thank you for the quick answer @skarzi
Do you think it would be possible to add this feature to the package? I would be willing to help.

Yes, it would be 😉 If you want to contribute this feature I'd be happy to review it. Best, Joe