class Raamen::Static

Attributes

app[R]
file_server[R]
root[R]

Public Class Methods

new(app) click to toggle source
# File lib/raamen/static.rb, line 5
def initialize(app)
  @app = app
  @root = :public
  @file_server = FileServer.new(self.root)
end

Public Instance Methods

call(env) click to toggle source
# File lib/raamen/static.rb, line 11
def call(env)
  req = Rack::Request.new(env)
  path = req.path

  if path.include?("/#{self.root}")
    res = self.file_server.call(env)
  else
    res = self.app.call(env)
  end

  res
end