Skip to content

Commit 3ba7dd8

Browse files
committed
Merge pull request #1036 from dblock/upgrading
Added note on upgrading from #1029.
2 parents e0b7357 + 04f179f commit 3ba7dd8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

UPGRADING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,34 @@ Upgrading Grape
33

44
### Upgrading to >= 0.12.0
55

6+
#### Changes in middleware
7+
8+
The Rack response object is no longer converted to an array by the formatter, enabling streaming. If your custom middleware is accessing `@app_response`, update it to expect a `Rack::Response` instance instead of an array.
9+
10+
For example,
11+
12+
```ruby
13+
class CacheBusterMiddleware < Grape::Middleware::Base
14+
def after
15+
@app_response[1]['Expires'] = Time.at(0).utc.to_s
16+
@app_response
17+
end
18+
end
19+
```
20+
21+
becomes
22+
23+
```ruby
24+
class CacheBusterMiddleware < Grape::Middleware::Base
25+
def after
26+
@app_response.headers['Expires'] = Time.at(0).utc.to_s
27+
@app_response
28+
end
29+
end
30+
```
31+
32+
See [#1029](https://github.com/intridea/grape/pull/1029) for more information.
33+
634
#### Changes in present
735

836
Using `present` with objects that responded to `merge` would cause early evaluation of the represented object, with unexpected side-effects, such as missing parameters or environment within rendering code. Grape now only merges represented objects with a previously rendered body, usually when multiple `present` calls are made in the same route.

0 commit comments

Comments
 (0)