server/handlerwrappers/default.rb in cpee-1.3.119 vs server/handlerwrappers/default.rb in cpee-1.3.120

- old
+ new

@@ -39,9 +39,22 @@ type = parameters[:method] || 'post' client = Riddl::Client.new(@handler_endpoint) status, result, headers = client.request type => params raise "Could not #{parameters[:method] || 'post'} #{@handler_endpoint}" if status != 200 + if result.length == 1 + if result[0].is_a? Riddl::Parameter::Simple + result = result[0] + elsif result[0].is_a? Riddl::Parameter::Complex + if result[0].mimetype == 'application/json' + result = JSON::parse(result[0].value.read) + elsif result[0].mimetype == 'application/xml' || result[0].mimetype == 'text/xml' + result = XML::Smart::string(result[0].value.read) + else + result = result[0] + end + end + end if headers["CPEE_CALLBACK"] && headers["CPEE_CALLBACK"] == 'true' @controller.callbacks[callback] = CPEE::Callback.new("callback activity: #{@handler_position}",self,:callback,nil,nil,:http) @handler_passthrough = callback return