Class: FileServer

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

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/static.rb', line 32

def call(env)
  res = Rack::Response.new
  file_name = requested_file_name(env)

  if File.exist?(file_name)
    serve_file(file_name, res)
  else
    res.status = 404
    res.write("File not found")
  end
  res
end