Class: ICFS::Demo::Static Deprecated
- Inherits:
-
Object
- Object
- ICFS::Demo::Static
- Defined in:
- lib/icfs/demo/static.rb
Overview
Deprecated.
This is a horrible implementation, DO NOT USE for anything other than testing.
Serve static files - Rack middleware
Instance Method Summary collapse
-
#call(env) ⇒ Object
Process requests.
-
#initialize(app, stat) ⇒ Static
constructor
New instance.
Constructor Details
#initialize(app, stat) ⇒ Static
New instance
33 34 35 36 |
# File 'lib/icfs/demo/static.rb', line 33 def initialize(app, stat) @stat = stat @app = app end |
Instance Method Details
#call(env) ⇒ Object
Process requests
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/icfs/demo/static.rb', line 39 def call(env) # see if we have a static file to serve st = @stat[env['PATH_INFO']] if st cont = File.read(st['path']) head = { 'Content-Type' => st['mime'], 'Content-Length' => cont.bytesize.to_s } return [200, head, [cont]] end return @app.call(env) end |