Class: Opi::Response

Inherits:
Rack::Response
  • Object
show all
Defined in:
lib/opi/response.rb

Instance Method Summary collapse

Constructor Details

#initializeResponse

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.message}\"}", "\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