Method: Bunch::Rack#call

Defined in:
lib/bunch/rack.rb

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/bunch/rack.rb', line 16

def call(env)
  path = @root.join(env['PATH_INFO'].sub(/^\//, '')).to_s
  type = MIME::Types.type_for(path).first || 'text/plain'

  [200, headers(type), [content_for(path)]]
rescue => e
  [500, headers('text/plain'), [error_log(e)]]
end