TODO(anand): Use the serialize/deserialize from common/http.hpp when they are available.
| 86 | // TODO(anand): Use the serialize/deserialize from common/http.hpp |
| 87 | // when they are available. |
| 88 | Try<Event> deserialize(const string& contentType, const string& body) |
| 89 | { |
| 90 | if (contentType == APPLICATION_PROTOBUF) { |
| 91 | Event event; |
| 92 | if (!event.ParseFromString(body)) { |
| 93 | return Error("Failed to parse body into Event protobuf"); |
| 94 | } |
| 95 | return event; |
| 96 | } |
| 97 | |
| 98 | Try<JSON::Value> value = JSON::parse(body); |
| 99 | Try<Event> parse = ::protobuf::parse<Event>(value.get()); |
| 100 | return parse; |
| 101 | } |
| 102 | |
| 103 | string serialize(const Call& call, const string& contentType) |
| 104 | { |