Class: Orbit::Response

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body = [], status = 200, header = {}) ⇒ Response

Returns a new instance of Response.



3
4
5
6
# File 'lib/orbit/response.rb', line 3

def initialize(body=[], status=200, header={})
  super
  headers['Content-Type'] ||= 'text/html'
end

Class Method Details

.not_found(verb, path) ⇒ Object



8
9
10
11
12
# File 'lib/orbit/response.rb', line 8

def self.not_found(verb, path)
  body = ["Oops! No route for #{verb} #{path}"]

  [404, {}, body]
end

.server_error(exception, verb, path) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/orbit/response.rb', line 14

def self.server_error(exception, verb, path)
  body =  "Error processing: #{verb} #{path}\n\n"
  body += "#{exception.class.name}: #{exception.to_s}\n\n"
  body += "Backtrace:\n\t#{exception.backtrace.join("\n\t")}"

  Config.logger.error body

  [500, {}, [body]]
end