Class: Hanami::API::Middleware::App Private
- Inherits:
-
Object
- Object
- Hanami::API::Middleware::App
- Defined in:
- lib/hanami/api/middleware/app.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Hanami::API middleware stack
Instance Method Summary collapse
- #call(env) ⇒ Object private
-
#initialize(app, mapping) ⇒ App
constructor
private
A new instance of App.
Constructor Details
#initialize(app, mapping) ⇒ App
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 App.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hanami/api/middleware/app.rb', line 15 def initialize(app, mapping) @trie = Hanami::API::Middleware::Trie.new(app) mapping.each do |path, stack| builder = Rack::Builder.new stack.each do |middleware, args, blk| builder.use(middleware, *args, &blk) end builder.run(app) @trie.add(path, builder.to_app.freeze) end @trie.freeze 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.
35 36 37 |
# File 'lib/hanami/api/middleware/app.rb', line 35 def call(env) @trie.find(env["PATH_INFO"]).call(env) end |