Class: Synthra::APIServer::WEBrickResponse
- Inherits:
-
Object
- Object
- Synthra::APIServer::WEBrickResponse
- Defined in:
- lib/synthra/api_server.rb
Overview
Response adapter for WEBrick
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #body=(content) ⇒ Object
- #content_type=(type) ⇒ Object
-
#initialize(res) ⇒ WEBrickResponse
constructor
A new instance of WEBrickResponse.
- #json(data) ⇒ Object
Constructor Details
#initialize(res) ⇒ WEBrickResponse
Returns a new instance of WEBrickResponse.
622 623 624 625 |
# File 'lib/synthra/api_server.rb', line 622 def initialize(res) @res = res @headers = {} end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
620 621 622 |
# File 'lib/synthra/api_server.rb', line 620 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status.
619 620 621 |
# File 'lib/synthra/api_server.rb', line 619 def status @status end |
Instance Method Details
#body=(content) ⇒ Object
639 640 641 |
# File 'lib/synthra/api_server.rb', line 639 def body=(content) @res.body = content end |
#content_type=(type) ⇒ Object
635 636 637 |
# File 'lib/synthra/api_server.rb', line 635 def content_type=(type) @res["Content-Type"] = type end |
#json(data) ⇒ Object
643 644 645 646 |
# File 'lib/synthra/api_server.rb', line 643 def json(data) @res["Content-Type"] = "application/json" @res.body = JSON.pretty_generate(data) end |