class Opi::Response

Public Class Methods

new() click to toggle source
# 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

Public Instance Methods

internal_server_error!(exception) click to toggle source
# 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!() click to toggle source
# File lib/opi/response.rb, line 12
def not_found!
  @status = 404
  @body = ["{\"error\":\"404 Not Found\"}", "\n"]
end