File tree Expand file tree Collapse file tree 4 files changed +13
-0
lines changed
Expand file tree Collapse file tree 4 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ gem 'rack-cors'
66gem 'grape-swagger'
77gem 'activemodel'
88gem 'kaminari' , require : 'kaminari/grape'
9+ gem 'rack-rewrite'
910
1011group :development do
1112 gem 'rake'
Original file line number Diff line number Diff line change 9999 rack-cors (0.4.0 )
100100 rack-mount (0.8.3 )
101101 rack (>= 1.0.0 )
102+ rack-rewrite (1.4.1 )
102103 rack-test (0.6.3 )
103104 rack (>= 1.0 )
104105 rails-deprecated_sanitizer (1.0.3 )
@@ -158,6 +159,7 @@ DEPENDENCIES
158159 hyperclient
159160 kaminari
160161 rack-cors
162+ rack-rewrite
161163 rack-test
162164 rake
163165 rspec
Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ def self.instance
1818 end
1919 end
2020
21+ # rewrite HAL links to make them clickable in a browser
22+ use Rack ::Rewrite do
23+ r302 %r{^(\/ api\/ \w *\/ )(%7B|\{ )?(.*)(%7D|\} )$} , '$1'
24+ end
25+
2126 run Acme ::App . new
2227 end . to_app
2328 end
Original file line number Diff line number Diff line change @@ -25,4 +25,9 @@ def app
2525 expect ( JSON . parse ( last_response . body ) ) . to_not eq ( { } )
2626 end
2727 end
28+ it 'rewrites encoded HAL links to make them clickable' do
29+ get '/api/splines/%7B?cursor,size%7D'
30+ expect ( last_response . status ) . to eq 302
31+ expect ( last_response . headers [ 'Location' ] ) . to eq '/api/splines/'
32+ end
2833end
You can’t perform that action at this time.
0 commit comments