Class: Hanami::API::Router

Inherits:
Router
  • Object
show all
Defined in:
lib/hanami/api/router.rb

Overview

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(block_context: Block::Context, **kwargs) ⇒ Router

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 Router.

Since:

  • 0.1.0



12
13
14
15
# File 'lib/hanami/api/router.rb', line 12

def initialize(block_context: Block::Context, **kwargs)
  super(block_context: block_context, **kwargs)
  @stack = Middleware::Stack.new(@path_prefix.to_s)
end

Instance Method Details

#freezeObject

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.

Since:

  • 0.1.0



19
20
21
22
23
24
# File 'lib/hanami/api/router.rb', line 19

def freeze
  return self if frozen?

  remove_instance_variable(:@stack)
  super
end

#to_rack_appObject

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.

Since:

  • 0.1.1



34
35
36
# File 'lib/hanami/api/router.rb', line 34

def to_rack_app
  @stack.finalize(self)
end

#use(middleware, *args, &blk) ⇒ 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.

Since:

  • 0.1.0



28
29
30
# File 'lib/hanami/api/router.rb', line 28

def use(middleware, *args, &blk)
  @stack.use(@path_prefix.to_s, middleware, *args, &blk)
end