File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,21 @@ App = Webmachine::Application.new do |app|
2020 # but will not provide any path_info
2121 add [" orders" , :* ], OrderResource
2222
23+ # Will map to any path that matches the given components and regular expression
24+ # Any capture groups specified in the regex will be made available in
25+ # request.path_info[:captures. In this case, you would get one or two
26+ # values in :captures depending on whether your request looked like:
27+ # /orders/1/cancel
28+ # or
29+ # /orders/1/cancel.json
30+ add [" orders" , :id , /([^.] *) \. ?(.*) ?/ ], OrderResource
31+
32+ # You can even use named captures with regular expressions. This will
33+ # automatically put the captures into path_info. In the below example,
34+ # you would get :id from the symbol, along with :action and :format
35+ # from the regex. :format in this case would be optional.
36+ add [" orders" , :id , /(?<action>) [^.] *)\. ?(?<format>.*) ?/ ], OrderResource
37+
2338 # will map to any path
2439 add [:* ], DefaultResource
2540 end
94109request.path_info[:foo ]
95110=> " bar"
96111
97- ```
112+ ```
You can’t perform that action at this time.
0 commit comments