-
Notifications
You must be signed in to change notification settings - Fork 11
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
Get current status #5
Comments
I could see it as endpoint that returns current status
with response, {
"maintenance": true
} Seems to be easy one, if you fine with that please shoot PR, otherwise I can pack it in nearest future. |
My specific need is for other middlewares to know the status. Since middlewares don't have routes, maintenance can't attach itself as a callback to their requests. I want a proxy middleware to know whether we are in maintenance mode or not so it can decide whether to make certain calls and return sane responses. While a GET API would work, it would add some overhead of the app calling itself. |
I see several solutions.
var maintenance = require('maintenance');
// some other middleware
function foo(req, res, next) {
var current = maintanance.mode();
// use it further
}
module.exports = foo;
// other middleware
function foo(req, res, next) {
var current = req.maintenance;
} Both are fine, I bit more like second one. I wondering, with the latest changes you introduced that |
I think the second one is cleaner too, but either would work for me. The other middleware works because it's not a callback on a route. That could pose challenges with the second solution - since this is a non-route request, maintenance wouldn't be called to add the current status to the request object. I'll mess around with my setup to see if I can get maintenance to modify a request on my proxied URLs and if so send a PR. |
Sounds good. Please go ahead, if you need my help - just let me know :) |
It would be helpful if there was some way to get the current status of whether the maintenance modules is enabled or disabled. This is especially important when using the endpoint to toggle.
This would allow for more complex request handling in maintenance mode.
The text was updated successfully, but these errors were encountered: