class SimpleApiClient::TestingServer

Public Instance Methods

put_post_response() click to toggle source
# File lib/simple_api_client/testing_server.rb, line 38
def put_post_response
  data = request.body.read
  request.accept.each do |type|
    case type.to_s
    when 'application/json'
      content_type :json
      #if we get json we can parse it!
      output = JSON.parse(data).to_json
    when 'application/xml'
      content_type :xml
      #in-valid xml will raise an exception
      xml = Nokogiri::XML(data){|config| config.strict}
      output = xml.to_s
    end
    halt output
  end
  error 406
end