Class: Synthra::APIServer::RackResponse
- Inherits:
-
Object
- Object
- Synthra::APIServer::RackResponse
- Defined in:
- lib/synthra/api_server.rb
Overview
Response adapter for Rack
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #content_type=(type) ⇒ Object
-
#initialize ⇒ RackResponse
constructor
A new instance of RackResponse.
- #json(data) ⇒ Object
Constructor Details
#initialize ⇒ RackResponse
Returns a new instance of RackResponse.
702 703 704 705 706 |
# File 'lib/synthra/api_server.rb', line 702 def initialize @status = 200 @headers = { "Content-Type" => "application/json" } @body = "" end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
699 700 701 |
# File 'lib/synthra/api_server.rb', line 699 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
700 701 702 |
# File 'lib/synthra/api_server.rb', line 700 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status.
699 700 701 |
# File 'lib/synthra/api_server.rb', line 699 def status @status end |
Instance Method Details
#content_type=(type) ⇒ Object
708 709 710 |
# File 'lib/synthra/api_server.rb', line 708 def content_type=(type) @headers["Content-Type"] = type end |
#json(data) ⇒ Object
712 713 714 715 |
# File 'lib/synthra/api_server.rb', line 712 def json(data) @headers["Content-Type"] = "application/json" @body = JSON.pretty_generate(data) end |