Class: UState::Dash::Static

Inherits:
Object
  • Object
show all
Defined in:
lib/ustate/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/ustate/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/ustate/dash/rack/static.rb', line 8

def call(env)
  r = @file_server.call env
  if r[0] == 404   
    @app.call env
  else
    r
  end
end