Class: ProconBypassMan::ProconDisplay::HttpResponse
- Inherits:
-
Object
- Object
- ProconBypassMan::ProconDisplay::HttpResponse
- Defined in:
- lib/procon_bypass_man/procon_display/http_response.rb
Instance Method Summary collapse
-
#initialize(body, status:, format: "text/json") ⇒ HttpResponse
constructor
A new instance of HttpResponse.
- #to_s ⇒ Object
Constructor Details
#initialize(body, status:, format: "text/json") ⇒ HttpResponse
Returns a new instance of HttpResponse.
3 4 5 6 7 |
# File 'lib/procon_bypass_man/procon_display/http_response.rb', line 3 def initialize(body, status: , format: "text/json") @body = body&.to_json @status = status @format = format end |
Instance Method Details
#to_s ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/procon_bypass_man/procon_display/http_response.rb', line 9 def to_s <<~EOH HTTP/1.1 #{@status} Content-Length: #{@body&.bytes&.size || 0} Content-Type: #{@format} Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET Access-Control-Allow-Private-Network:true Connection: close #{@body} EOH end |