class Rack::Maintenance
Attributes
active[R]
body[R]
headers[R]
status[R]
template[R]
Public Class Methods
new(app, options = {})
click to toggle source
# File lib/rack/maintenance.rb, line 6 def initialize(app, options = {}) raise InvalidStatus if options[:status] && options[:status].to_i < 100 @app = app @status = options[:status] || default_status @headers = options[:headers] || default_headers @template = options[:template] || default_template @active = options[:active].nil? ? true : options[:active] end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/maintenance.rb, line 17 def call(env) if active? headers['Content-Length'] = body.bytesize.to_s return [status, headers, [body]] end @app.call(env) end
Private Instance Methods
active?()
click to toggle source
# File lib/rack/maintenance.rb, line 43 def active? !!@active end
default_headers()
click to toggle source
# File lib/rack/maintenance.rb, line 35 def default_headers {'Content-Type'=> 'text/html'} end
default_status()
click to toggle source
# File lib/rack/maintenance.rb, line 31 def default_status 503 end
default_template()
click to toggle source
# File lib/rack/maintenance.rb, line 39 def default_template "<h2>Sorry. We're under maintenance...<h2>" end