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)
- - (Object) call(env)
-
- (Static) initialize(app, public_dir = './public')
constructor
A new instance of Static.
Constructor Details
- (Static) initialize(app, public_dir = './public')
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 |