Method: Restify::Response#decoded_body

Defined in:
lib/restify/response.rb

#decoded_bodyArray, ...

Return decoded body according to content type. Will return nil if content cannot be decoded.

Returns:

  • (Array, Hash, NilClass)

    Decoded response body.



122
123
124
125
126
127
128
129
130
131
# File 'lib/restify/response.rb', line 122

def decoded_body
  @decoded_body ||= begin
    case headers['Content-Type']
    when /\Aapplication\/json($|;)/
      MultiJson.load body
    else
      nil
    end
  end
end