Class: Hanami::Middleware::PublicErrorsApp Private
- Inherits:
-
Object
- Object
- Hanami::Middleware::PublicErrorsApp
- Defined in:
- lib/hanami/middleware/public_errors_app.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The errors app given to RenderErrors, which renders error responses from HTML pages kept in ‘public/` as simple JSON structures.
Instance Attribute Summary collapse
- #public_path ⇒ Object readonly private
Instance Method Summary collapse
- #call(env) ⇒ Object private
-
#initialize(public_path) ⇒ PublicErrorsApp
constructor
private
A new instance of PublicErrorsApp.
Constructor Details
#initialize(public_path) ⇒ PublicErrorsApp
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of PublicErrorsApp.
21 22 23 |
# File 'lib/hanami/middleware/public_errors_app.rb', line 21 def initialize(public_path) @public_path = public_path end |
Instance Attribute Details
#public_path ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 |
# File 'lib/hanami/middleware/public_errors_app.rb', line 17 def public_path @public_path end |
Instance Method Details
#call(env) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hanami/middleware/public_errors_app.rb', line 27 def call(env) request = Rack::Request.new(env) status = request.path_info[1..].to_i content_type = request.get_header("HTTP_ACCEPT") default_body = { status: status, error: Rack::Utils::HTTP_STATUS_CODES.fetch(status, Rack::Utils::HTTP_STATUS_CODES[500]) } render(status, content_type, default_body) end |