Class: Shotgun::Static

Inherits:
Object
  • Object
show all
Defined in:
lib/shotgun/static.rb

Overview

Serves static files out of the specified directory.

Instance Method Summary (collapse)

Constructor Details

- (Static) initialize(app, public_dir = './public')

Returns a new instance of Static



6
7
8
9
# File 'lib/shotgun/static.rb', line 6

def initialize(app, public_dir='./public')
  @file = Rack::File.new(public_dir)
  @app = app
end

Instance Method Details

- (Object) call(env)



11
12
13
14
15
16
17
18
# File 'lib/shotgun/static.rb', line 11

def call(env)
  status, headers, body = @file.call(env)
  if status > 400
    @app.call(env)
  else
    [status, headers, body]
  end
end