Class: Opi::Response
- Inherits:
-
Rack::Response
- Object
- Rack::Response
- Opi::Response
- Defined in:
- lib/opi/response.rb
Instance Method Summary collapse
-
#initialize ⇒ Response
constructor
A new instance of Response.
- #internal_server_error!(exception) ⇒ Object
- #not_found! ⇒ Object
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
4 5 6 7 8 9 10 |
# File 'lib/opi/response.rb', line 4 def initialize @status, @body = 200, ["{}","\n"] @header = Rack::Utils::HeaderHash.new({ 'Content-Type' => 'application/json; charset=utf-8' # 'Server' => 'TBD/1.0' }) end |
Instance Method Details
#internal_server_error!(exception) ⇒ Object
17 18 19 20 |
# File 'lib/opi/response.rb', line 17 def internal_server_error!(exception) @status = 500 @body = ["{\"error\":\"500 Internal Server Error\", \"message\":\"#{exception.}\"}", "\n"] end |
#not_found! ⇒ Object
12 13 14 15 |
# File 'lib/opi/response.rb', line 12 def not_found! @status = 404 @body = ["{\"error\":\"404 Not Found\"}", "\n"] end |