From 6b2e0cb3aa2725606802a1f9f30b9e1231b1d1b8 Mon Sep 17 00:00:00 2001 From: dblock Date: Wed, 20 Feb 2013 13:16:18 -0500 Subject: [PATCH] Delete X-Cascade header for default behavior. --- CHANGELOG.markdown | 2 +- README.markdown | 2 +- lib/grape/api.rb | 4 ++-- spec/grape/api_spec.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 5134658740..e209d1b4a7 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -1,7 +1,7 @@ Next Release ============ -* [#340](https://github.com/intridea/grape/pull/339): Allow rack/mount cascading to be skipped on header - [@dieb](https://github.com/dieb). +* [#340](https://github.com/intridea/grape/pull/339), [#342](https://github.com/intridea/grape/pull/342): Added `:cascade` option to `version` to allow disabling of rack/mount cascade behavior - [@dieb](https://github.com/dieb). * [#333](https://github.com/intridea/grape/pull/333): Validation for array in params - [@flyerhzm](https://github.com/flyerhzm). * [#306](https://github.com/intridea/grape/issues/306): Added I18n support for all Grape exceptions - [@niedhui](https://github.com/niedhui). * [#294](https://github.com/intridea/grape/issues/294): Extracted `Grape::Entity` into a [grape-entity](https://github.com/agileanimal/grape-entity) gem - [@agileanimal](https://github.com/agileanimal). diff --git a/README.markdown b/README.markdown index 3954b959f9..8cb29a65e1 100644 --- a/README.markdown +++ b/README.markdown @@ -660,7 +660,7 @@ end When mounted inside Rails 3.x, errors like "404 Not Found" or "406 Not Acceptable" will likely be handled and rendered by Rails handlers. For instance, accessing a nonexistent route "/api/foo" -raises a 404, which inside rails will ultimately be translated to a ActionController::RoutingError, +raises a 404, which inside rails will ultimately be translated to an `ActionController::RoutingError`, which most likely will get rendered to a HTML error page. Most APIs will enjoy avoiding Rails exceptions and have their own exceptions reaching the client. diff --git a/lib/grape/api.rb b/lib/grape/api.rb index 40f0f73f60..493801dfb8 100644 --- a/lib/grape/api.rb +++ b/lib/grape/api.rb @@ -458,8 +458,8 @@ def initialize def call(env) status, headers, body = @route_set.call(env) - headers['X-Cascade'] = '' unless cascade? - [status, headers, body] + headers.delete('X-Cascade') unless cascade? + [ status, headers, body ] end # Some requests may return a HTTP 404 error if grape cannot find a matching diff --git a/spec/grape/api_spec.rb b/spec/grape/api_spec.rb index d9016e4852..4075dcfeff 100644 --- a/spec/grape/api_spec.rb +++ b/spec/grape/api_spec.rb @@ -1867,7 +1867,7 @@ def serializable_hash subject.version 'v2', :using => :path, :cascade => false get "/v2/hello" last_response.status.should == 404 - last_response.headers["X-Cascade"].should == "" + last_response.headers.keys.should_not include "X-Cascade" end end end