Class: Hanami::Middleware::App Private
- Inherits:
-
Object
- Object
- Hanami::Middleware::App
- Defined in:
- lib/hanami/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.
Instance Method Summary collapse
- #call(env) ⇒ Object private
-
#initialize(router, mapping) ⇒ App
constructor
private
A new instance of App.
- #to_inspect ⇒ Object private
Constructor Details
#initialize(router, 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.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/hanami/middleware/app.rb', line 18 def initialize(router, mapping) @trie = Hanami::Middleware::Trie.new(router) mapping.each do |path, stack| builder = Rack::Builder.new stack.each do |middleware, args, kwargs, blk| builder.use(middleware, *args, **kwargs, &blk) end builder.run(router) @trie.add(path, builder.to_app.freeze) end @trie.freeze @inspector = router.inspector.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.
39 40 41 |
# File 'lib/hanami/middleware/app.rb', line 39 def call(env) @trie.find(env[::Rack::PATH_INFO]).call(env) end |
#to_inspect ⇒ 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.
45 46 47 |
# File 'lib/hanami/middleware/app.rb', line 45 def to_inspect @inspector&.call.to_s end |