Sha256: 02e7e3d87c9e2fc5af9ea533721aecbc1ceb5548ddf957ea93885287e106aeb4

Contents?: true

Size: 834 Bytes

Versions: 3

Compression:

Stored size: 834 Bytes

Contents

# frozen_string_literal: true

require "hanami/router"
require "hanami/api/block/context"

module Hanami
  class API
    # @since 0.1.0
    class Router < ::Hanami::Router
      # @since 0.1.0
      # @api private
      def initialize(block_context: Block::Context, **kwargs)
        super(block_context: block_context, **kwargs)
        @stack = Middleware::Stack.new(@path_prefix.to_s)
      end

      # @since 0.1.0
      # @api private
      def freeze
        return self if frozen?

        remove_instance_variable(:@stack)
        super
      end

      # @since 0.1.0
      # @api private
      def use(middleware, *args, &blk)
        @stack.use(@path_prefix.to_s, middleware, *args, &blk)
      end

      # @since 0.1.1
      # @api private
      def to_rack_app
        @stack.finalize(self)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hanami-api-0.2.0 lib/hanami/api/router.rb
hanami-api-0.1.2 lib/hanami/api/router.rb
hanami-api-0.1.1 lib/hanami/api/router.rb