Class: Dragonfly::Middleware

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

Instance Method Summary collapse

Constructor Details

#initialize(app, dragonfly_app_name, path_prefix) ⇒ Middleware

Returns a new instance of Middleware.



4
5
6
7
8
9
10
11
# File 'lib/dragonfly/middleware.rb', line 4

def initialize(app, dragonfly_app_name, path_prefix)
  @app = app
  @endpoint = Rack::Builder.new {
    map path_prefix do
      run Dragonfly[dragonfly_app_name]
    end
  }.to_app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/dragonfly/middleware.rb', line 13

def call(env)
  response = @endpoint.call(env)
  if route_not_found?(response)
    @app.call(env)
  else
    response
  end
end