From 04f179fe88d407156ea40b592fbd0475b3535616 Mon Sep 17 00:00:00 2001 From: dblock Date: Wed, 17 Jun 2015 14:32:45 -0400 Subject: [PATCH] Added note on upgrading from #1029. --- UPGRADING.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/UPGRADING.md b/UPGRADING.md index 95a2a6c9f..88bc7b8b3 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -3,6 +3,34 @@ Upgrading Grape ### Upgrading to >= 0.12.0 +#### Changes in middleware + +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. + +For example, + +```ruby +class CacheBusterMiddleware < Grape::Middleware::Base + def after + @app_response[1]['Expires'] = Time.at(0).utc.to_s + @app_response + end +end +``` + +becomes + +```ruby +class CacheBusterMiddleware < Grape::Middleware::Base + def after + @app_response.headers['Expires'] = Time.at(0).utc.to_s + @app_response + end +end +``` + +See [#1029](https://github.com/intridea/grape/pull/1029) for more information. + #### Changes in present 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.