Class: Riemann::Dash::Static

Inherits:
Object
  • Object
show all
Defined in:
lib/riemann/dash/rack/static.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Static

Returns a new instance of Static.



2
3
4
5
6
# File 'lib/riemann/dash/rack/static.rb', line 2

def initialize(app, options = {})
  @app = app
  @root = options[:root] or raise ArgumentError, "no root"
  @file_server = ::Rack::File.new(@root)
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/riemann/dash/rack/static.rb', line 8

def call(env)
  r = @app.call env
  if r[0] < 200 or 400 <= r[0]
    @file_server.call env
  else
    r
  end
end