Class: StaticViewer

Inherits:
Object
  • Object
show all
Defined in:
lib/db/static_viewer.rb

Constant Summary collapse

FILE_TYPE =
{
  'jpg' => 'image/jpeg',
  'zip' => 'application/zip',
  'png' => 'image/png',
  'txt' => 'text/plain'
}

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ StaticViewer

Returns a new instance of StaticViewer.



12
13
14
# File 'lib/db/static_viewer.rb', line 12

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/db/static_viewer.rb', line 16

def call(env)
  if is_public?(env)
    req = Rack::Request.new(env)
    res = Rack::Response.new

    file_path = "#{req.path}"
    build_response(res, file_path)
  else
    @app.call(env)
  end
end