I'm considering adding support for Protocol Buffers to the RESTful application that I'm currently working on, and was wondering what people thought.
I'm aware of all the arguments against using binary formats in REST APIs - but we deal with some pretty big sets of data on our project, and the speed and compactness of Protocol Buffers compared to XML/JSON is just too tempting. So here's how I'm thinking we might implement things:
- XML will remain the default representation for all resources.
- If the client includes the
application/x-protobufMIME type in theirAcceptheader, the server will return a Protocol Buffer instead (and set theContent-Typetoapplication/x-protobuf). - When a Protocol Buffer is returned, the HTTP response will also include an
X-Protobuf-Schemaheader containing the URI for the.protoschema file.

3 comments:
Did you follow through with this approach? I'm thinking about doing something very similar but with JSON as the default.
No, I switched jobs recently and unfortunately didn't get around to implementing the protobuf thing at my old company before I left.
It was pretty straight-forward with JAX-RS:
http://www.javarants.com/2008/12/27/using-jax-rs-with-protocol-buffers-for-high-performance-rest-apis/
Sam
Post a Comment