Skip to content

Instantly share code, notes, and snippets.

@saranyan
Created March 30, 2012 15:52
Show Gist options
  • Select an option

  • Save saranyan/2252401 to your computer and use it in GitHub Desktop.

Select an option

Save saranyan/2252401 to your computer and use it in GitHub Desktop.
HT build a X.commerce capability PingPong
<?php
$schema_uri = $headers['X-XC-SCHEMA-URI'];
//deserialize the data
$content = file_get_contents($schema_uri);
$schema = AvroSchema::parse($content);
$datum_reader = new AvroIODatumReader($schema);
$read_io = new AvroStringIO($post_data);
$decoder = new AvroIOBinaryDecoder($read_io);
$message = $datum_reader->read($decoder);
file = HTTParty.get(headers["X_XC_SCHEMA_URI"])
#deserialize
schema = Avro::Schema.parse(file.parsed_response.to_s.gsub(/\=\>/,':'))
stringreader = StringIO.new(message_body)
decoder = Avro::IO::BinaryDecoder.new(stringreader)
datumreader = Avro::IO::DatumReader.new(schema)
#read the message
read_value = datumreader.read(decoder)
<?php
$post_data = file_get_contents("php://input");
$headers = getallheaders();
message_body = request.env["rack.input"].read
headers = request_headers
<?php
if ($headers["AUTHORIZATION"] == $fabric_token) {
//stuff
}
if fabric_token == request_headers["AUTHORIZATION"]
#stuff
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment