Class: Sparrow::ResponseHttpMessage

Inherits:
HttpMessage show all
Defined in:
lib/sparrow/response_http_message.rb

Constant Summary

Constants inherited from HttpMessage

HttpMessage::FORM_HASH_KEY, HttpMessage::RACK_INPUT_KEY

Instance Attribute Summary collapse

Attributes inherited from HttpMessage

#env

Instance Method Summary collapse

Methods inherited from HttpMessage

#accept, #form_hash?, #initialize, #method_missing, #request

Constructor Details

This class inherits a constructor from Sparrow::HttpMessage

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Sparrow::HttpMessage

Instance Attribute Details

#bodyObject

Returns the HTTP response body.

Returns:

  • the HTTP response body



9
10
11
# File 'lib/sparrow/response_http_message.rb', line 9

def body
  @body
end

#headersObject

Returns the HTTP header after the middleware was called.

Returns:

  • the HTTP header after the middleware was called



13
14
15
# File 'lib/sparrow/response_http_message.rb', line 13

def headers
  @headers
end

#statusInteger

Returns the HTTP Response Code status.

Returns:

  • (Integer)

    the HTTP Response Code status



5
6
7
# File 'lib/sparrow/response_http_message.rb', line 5

def status
  @status
end

Instance Method Details

#content_typeObject



31
32
33
# File 'lib/sparrow/response_http_message.rb', line 31

def content_type
  response.content_type.presence || super
end

#pathObject



27
28
29
# File 'lib/sparrow/response_http_message.rb', line 27

def path
  super
end

#responseObject

The wrapped Response instance

Returns:

  • (Object)

    the response



18
19
20
21
22
23
24
25
# File 'lib/sparrow/response_http_message.rb', line 18

def response
  clazz = response_class
  @response ||= if clazz.name == 'ActionDispatch::Response'
                  clazz.new(status, headers_hash, body)
                else
                  clazz.new(body, status, headers_hash)
                end
end