Class: Shotgun::Static
- Inherits:
-
Object
- Object
- Shotgun::Static
- Defined in:
- lib/shotgun/static.rb
Overview
Serves static files out of the specified directory.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, public_dir = './public') ⇒ Static
constructor
A new instance of Static.
Constructor Details
#initialize(app, public_dir = './public') ⇒ Static
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
#call(env) ⇒ Object
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 |