Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactored out magic values in Junkfood::Rack::ErrorHandler to consta…

…nts.
  • Loading branch information...
commit 40d96265372fc3b9f1f78c1d9ea75f56d262fcc9 1 parent ce68a74
@byu authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 lib/junkfood/rack/error.rb
View
12 lib/junkfood/rack/error.rb
@@ -56,7 +56,15 @@ module Rack
class ErrorHandler
##
# The default HTTP status code for caught errors.
- DEFAULT_STATUS_CODE = 500
+ DEFAULT_STATUS_CODE = 500.freeze
+
+ ##
+ # Header to set the content type of error response
+ CONTENT_TYPE = 'Content-Type'.freeze
+
+ ##
+ # Json's content type value for the content type header.
+ JSON_CONTENT_TYPE = 'application/json'.freeze
##
# @param app the rest of the rack stack
@@ -84,7 +92,7 @@ def call(env)
return [
map['status_code'] ? map['status_code'].to_i : DEFAULT_STATUS_CODE,
- { 'Content-Type' => 'application/json' },
+ { CONTENT_TYPE => JSON_CONTENT_TYPE },
[error.to_json]]
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.