class Bezel::StaticAssets

Public Class Methods

new(app) click to toggle source
# File lib/static_assets.rb, line 3
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/static_assets.rb, line 7
def call(env)
  file_path = "." + env['PATH_INFO']
  if file_path =~ (/app\/assets/)
    res = Rack::Response.new
    extension = File.extname(file_path)
      begin
        extension = ".json" if extension == ".map"
        res["Content-Type"] = Rack::Mime::MIME_TYPES[extension]
        content = File.read(file_path)
        res.write(content)
      rescue
        res.status = 404
      end
      res.finish
  else
    @app.call(env)
  end
end