Class: Scorched::Request
- Inherits:
-
Rack::Request
- Object
- Rack::Request
- Scorched::Request
- Defined in:
- lib/scorched/request.rb
Instance Method Summary collapse
-
#all_captures ⇒ Object
Returns an array of capture arrays; one for each mapping that’s been hit during the request processing so far.
-
#breadcrumb ⇒ Object
Keeps track of the matched URL portions and what object handled them.
-
#captures ⇒ Object
Returns a hash of captured strings from the last matched URL in the breadcrumb.
-
#matched_path ⇒ Object
The portion of the path that’s currently been matched by one or more mappings.
-
#unescaped_path ⇒ Object
The unescaped URL, excluding the escaped forward-slash and percent.
-
#unmatched_path ⇒ Object
The remaining portion of the path that has yet to be matched by any mappings.
Instance Method Details
#all_captures ⇒ Object
Returns an array of capture arrays; one for each mapping that’s been hit during the request processing so far.
17 18 19 |
# File 'lib/scorched/request.rb', line 17 def all_captures .map { |match| match.captures } end |
#breadcrumb ⇒ Object
Keeps track of the matched URL portions and what object handled them. Useful for debugging and building breadcrumb navigation.
7 8 9 |
# File 'lib/scorched/request.rb', line 7 def env['scorched.breadcrumb'] ||= [] end |
#captures ⇒ Object
Returns a hash of captured strings from the last matched URL in the breadcrumb.
12 13 14 |
# File 'lib/scorched/request.rb', line 12 def captures .last ? .last.captures : [] end |
#matched_path ⇒ Object
The portion of the path that’s currently been matched by one or more mappings.
22 23 24 |
# File 'lib/scorched/request.rb', line 22 def matched_path join_paths(.map{ |match| match.path }) end |
#unescaped_path ⇒ Object
The unescaped URL, excluding the escaped forward-slash and percent. The resulting string will always be safe to unescape again in situations where the forward-slash or percent are expected and valid characters.
35 36 37 |
# File 'lib/scorched/request.rb', line 35 def unescaped_path path_info.split(/(%25|%2F)/i).each_slice(2).map { |v, m| CGI.unescape(v) << (m || '') }.join('') end |
#unmatched_path ⇒ Object
The remaining portion of the path that has yet to be matched by any mappings.
27 28 29 30 31 |
# File 'lib/scorched/request.rb', line 27 def unmatched_path path = unescaped_path path[0,0] = '/' if (path[0] != '/' && matched_path[-1] == '/') || path.empty? path end |