Class: SimpleApiClient::TestingServer

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/simple_api_client/testing_server.rb

Instance Method Summary collapse

Instance Method Details

#put_post_responseObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# 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