Deny entire application with Rack?
I have a client who wishes to lock their entire application under certain conditions. This seems like a good job for Rack Middleware, so I wrote the following:
class Duress
def initialize(app)
@app = app
end
def call(env)
if env['UNDER_DURESS'] == true
# Return HTTP 503 - Service Unavailable
[503, {"Content-Type" => "text/html"},["<h1>Service Unavailable.</h1><p>Please try again later.</p>"]]
else
@app.call(env)
end
end
end
Firstly, I am not sure if an environment variable is necessary or even best practice, so I am open to ideas here. I am not even sure the above code will work.
Secondly, I am having problems hooking into the Devise login process to set this environment variable. I have tried over riding the after_sign_in_path_for method in application_controller, but it does not seem to to tr开发者_开发知识库iggered. Any tips here?
精彩评论