I am trying to build an API with Sinatra and MessagePack but I am about to shoot myself :)
So I am using curl to do a POST:
curl -X POST -H "Content-Type: application/x-msgpack" --data-binary '\x82\xA4uuid\xBD8asd76a-a8s7a6d87-asd76as8d76\xABcampaign_id\xA12' http://localhost:9393/
Now in Sinatra I just do:
MessagePack.unpack request.body.read
And this leads to the following error:
MessagePack::MalformedFormatError Exception: extra bytes follow after a deserialized object
Because request.body.read is returning:
"\\x82\\xA4uuid\\xBD8asd76a-a8s7a6d87-asd76as8d76\\xABcampaign_id\\xA12"
instead of
"\x82\xA4uuid\xBD8asd76a-a8s7a6d87-asd76as8d76\xABcampaign_id\xA12"
I tried everything I could think of like force_encoding(Encode::BINARY) and other stupid things. And I am not sure who is causing the problem ruby, rack or sinatra?