Class: Microcon::Response
- Inherits:
-
Object
- Object
- Microcon::Response
- Defined in:
- lib/microcon/response.rb
Overview
< BasicRequest
Instance Method Summary collapse
- #encode(body) ⇒ Object
-
#initialize(status:, body: {}, headers: {}) ⇒ Response
constructor
A new instance of Response.
- #to_rack ⇒ Object
Constructor Details
#initialize(status:, body: {}, headers: {}) ⇒ Response
Returns a new instance of Response.
4 5 6 7 8 |
# File 'lib/microcon/response.rb', line 4 def initialize(status:, body: {}, headers: {}) @status = status @body = encode(body) @headers = headers.merge Rack::CONTENT_TYPE => "application/json; charset=utf-8" end |
Instance Method Details
#encode(body) ⇒ Object
10 11 12 13 |
# File 'lib/microcon/response.rb', line 10 def encode(body) # TODO transformation Oj.dump(body) end |
#to_rack ⇒ Object
15 16 17 |
# File 'lib/microcon/response.rb', line 15 def to_rack [@status, @headers, [@body]] end |