Sha256: 69850be9ecfc32933df4e9756f3f70519cdddbf7145d7bf2bdd5232849447b0b
Contents?: true
Size: 1020 Bytes
Versions: 4
Compression:
Stored size: 1020 Bytes
Contents
# frozen_string_literal: true require "rack/builder" require_relative "./trie" module Hanami module Middleware # Hanami Rack middleware stack # @since 2.0.0 # @api private class App # @param router [Hanami::Router] # @param mapping [Hash] # # @since 2.0.0 # @api private def initialize(router, mapping) @trie = Hanami::Middleware::Trie.new(router) mapping.each do |path, stack| builder = Rack::Builder.new stack.each do |middleware, args, blk| builder.use(middleware, *args, &blk) end builder.run(router) @trie.add(path, builder.to_app.freeze) end @trie.freeze @inspector = router.inspector.freeze end # @since 2.0.0 # @api private def call(env) @trie.find(env[::Rack::PATH_INFO]).call(env) end # @since 2.0.0 # @api private def to_inspect @inspector&.call.to_s end end end end
Version data entries
4 entries across 4 versions & 1 rubygems