Class: Hanami::Assets::Middleware

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

Overview

Rack middleware for serving assets in development

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(app, assets) ⇒ Middleware

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Middleware.

Since:

  • 0.1.0



12
13
14
15
# File 'lib/hanami/sprockets/middleware.rb', line 12

def initialize(app, assets)
  @app = app
  @assets = assets
end

Instance Method Details

#call(env) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



19
20
21
22
23
24
25
26
27
28
# File 'lib/hanami/sprockets/middleware.rb', line 19

def call(env)
  request = Rack::Request.new(env)

  # Check if this is an asset request
  if asset_request?(request.path)
    serve_asset(request.path)
  else
    @app.call(env)
  end
end