class Rack::Backstage

Constants

File

Public Class Methods

new(app, path) click to toggle source
# File lib/rack/contrib/backstage.rb, line 5
def initialize(app, path)
  @app = app
  @file = File.expand_path(path)
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack/contrib/backstage.rb, line 10
def call(env)
  if File.exists?(@file)
    content = File.read(@file)
    length = "".respond_to?(:bytesize) ? content.bytesize.to_s : content.size.to_s
    [503, {'Content-Type' => 'text/html', 'Content-Length' => length}, [content]]
  else
    @app.call(env)
  end
end