Class: Pancake::Router
- Inherits:
-
HttpRouter
- Object
- HttpRouter
- Pancake::Router
show all
- Defined in:
- lib/pancake/router.rb
Overview
The pancake router uses a http_router router
Defined Under Namespace
Classes: MountedApplication, RackApplicationExpected
Constant Summary
collapse
- CONFIGURATION_KEY =
"pancake.request.configuration".freeze
- ROUTE_KEY =
"pancake.request.matching_route".freeze
- LAYOUT_KEY =
"pancake.apply_layout".freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#configuration ⇒ Object
44
45
46
|
# File 'lib/pancake/router.rb', line 44
def configuration
@configuration
end
|
37
38
39
|
# File 'lib/pancake/router.rb', line 37
def stack
@stack
end
|
Instance Method Details
#base_url(opts = {}) ⇒ Object
110
111
112
|
# File 'lib/pancake/router.rb', line 110
def base_url(opts = {})
url_mount.nil? ? "/" : url_mount.url(opts)
end
|
82
83
84
85
|
# File 'lib/pancake/router.rb', line 82
def dup
puts "Called DUP: #{caller.first}"
clone
end
|
#mount(mounted_app, path, options = {}) ⇒ Object
Mounts an application in the router as a sub application in the url space. This will route directly to the sub application and skip any middlewares etc defined on a stack
90
91
92
93
94
|
# File 'lib/pancake/router.rb', line 90
def mount(mounted_app, path, options = {})
mounted_app = MountedApplication.new(mounted_app, path, options)
self.class.mounted_applications << mounted_app
mounted_app
end
|
#mount_applications! ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/pancake/router.rb', line 96
def mount_applications!
apps = self.class.mounted_applications.select do |a|
a.mounted? ? false : (a.mounted = true)
end
apps.each do |app|
route = add(app.mount_path, app.options)
app.mount!(route)
end
end
|