Sha256: 6c12428b048b85ca286da3ca34d3bf84b3018cd50f01376508ea517d2862763d
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true require "hanami/router" require "hanami/application/routing/middleware/stack" module Hanami class Application # Hanami application router # @since 2.0.0 class Router < ::Hanami::Router # @since 2.0.0 # @api private def initialize(routes:, stack: Routing::Middleware::Stack.new, **kwargs, &blk) @stack = stack instance_eval(&blk) super(**kwargs, &routes) end # @since 2.0.0 # @api private def freeze return self if frozen? remove_instance_variable(:@stack) super end # @since 2.0.0 # @api private def use(middleware, *args, &blk) @stack.use(middleware, *args, &blk) end # @since 2.0.0 # @api private def scope(*args, &blk) @stack.with(args.first) do super end end # @since 2.0.0 def slice(name, at:, &blk) path = prefixed_path(at) @resolver.register_slice_at_path(name, path) scope(path, &blk) end # @since 2.0.0 # @api private def to_rack_app return self if @stack.empty? @stack.to_rack_app(self) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hanami-2.0.0.alpha4 | lib/hanami/application/router.rb |
hanami-2.0.0.alpha3 | lib/hanami/application/router.rb |
hanami-2.0.0.alpha2 | lib/hanami/application/router.rb |