Class: Synthra::APIServer::WEBrickResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/synthra/api_server.rb

Overview

Response adapter for WEBrick

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#headersObject (readonly)

Returns the value of attribute headers.



620
621
622
# File 'lib/synthra/api_server.rb', line 620

def headers
  @headers
end

#statusObject

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