Class: Stapler::Middleware

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

Instance Method Summary collapse

Constructor Details

#initialize(app, opts = {}) ⇒ Middleware

Returns a new instance of Middleware.



6
7
8
9
# File 'lib/stapler/middleware.rb', line 6

def initialize(app, opts = {})
  @app = app
  @config = Stapler::Config.new(opts)
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/stapler/middleware.rb', line 11

def call(env)
  path_info = env["PATH_INFO"]

  if path_info =~ @config.bundle_regex
    _call_bundle(env, Rack::Utils.unescape($1))
  elsif path_info =~ @config.path_regex
    _call_asset(env, Rack::Utils.unescape($1))
  else
    @app.call(env)
  end
end