Class: FontAssets::Middleware::FontAssetsRequest

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

Instance Method Summary collapse

Constructor Details

#initialize(middleware, env) ⇒ FontAssetsRequest

Returns a new instance of FontAssetsRequest.


22
23
24
25
# File 'lib/font_assets/middleware.rb', line 22

def initialize(middleware, env)
  @middleware = middleware
  @request = Rack::Request.new(env)
end

Instance Method Details

#do_requestObject


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/font_assets/middleware.rb', line 27

def do_request
  if font_asset?
    if @request.options?
      return [200, access_control_headers, []]
    else
      code, headers, body = yield

      headers.merge!(access_control_headers)
      headers.merge!('Content-Type' => mime_type) if headers['Content-Type']

      [code, headers, body]
    end
  else
    yield
  end
end