Skip to content

Commit

Permalink
Add support for HTTP 410 Gone responses (#77)
Browse files Browse the repository at this point in the history
* Add support for HTTP 410 Gone responses

At the moment, if your service returns an HTTP 410 Gone status code,
routemaster-drain treats it as a fatal error. This is... somewhat
sub-optimal, as we're returning 410s from lots of services on Heroku as
we migrate to AWS.

This adds a new error type (`ResourceGone`) which is thrown if
routemaster-drain receives a 410.

* Add note to CHANGELOG
  • Loading branch information
mcmillan authored and humzashah committed Mar 7, 2018
1 parent 287e2d8 commit 99f8eee
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### HEAD

_A description of your awesome changes here!_

Features:

- Raises more semantically correct error on 410

### 3.4.0 (2017-11-16)

Features:
Expand Down
6 changes: 6 additions & 0 deletions lib/routemaster/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def message
end
end

class ResourceGone < BaseError
def message
"Resource Gone: #{env.url}"
end
end

class FatalResource < BaseError
def message
"Fatal Resource Error. body: #{body}, url: #{env.url}, method: #{env.method}"
Expand Down
1 change: 1 addition & 0 deletions lib/routemaster/middleware/error_handling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ErrorHandling < Faraday::Response::Middleware
(404..404) => Errors::ResourceNotFound,
(405..405) => Errors::MethodNotAllowed,
(409..409) => Errors::ConflictResource,
(410..410) => Errors::ResourceGone,
(412..412) => Errors::IncompatibleVersion,
(413..413) => Errors::InvalidResource,
(429..429) => Errors::ResourceThrottling,
Expand Down

0 comments on commit 99f8eee

Please sign in to comment.