class Kraftwerk::Router
Constants
- DEFAULT_RESPONSE
Attributes
routes[R]
Public Class Methods
new(&block)
click to toggle source
# File lib/kraftwerk/router.rb, line 17 def initialize(&block) @routes = create_routing(&Proc.new(&block)) end
Private Instance Methods
create_routing(&block)
click to toggle source
# File lib/kraftwerk/router.rb, line 23 def create_routing(&block) # default_app is an undocumented feature of Hanami router coming from # HttpRouter library, which it relies upon. # It sets a default handler when no route can be matched. # See: https://github.com/hanami/router/issues/119 # # In hanami-router 2.0 it has been renamed to not_found default_app = ->(_env) { DEFAULT_RESPONSE } @routes = Hanami::Router.new(not_found: default_app) do instance_exec(&Proc.new(&block)) end end