Regarding rule #4 (DON'T return arrays as top level responses), I feel that meta information returned about the collection really fits the responsibility of HTTP headers. This is similar to existing response headers like Content-Length and Content-Range. REST clients already work with “out-of-band” information like HTTP statuses and If-Modified-Since. Do we always have add yet another layer to nest meta information i…
I struggle with this concept with RabbitMQ as well. The AMQP 0-9-1 protocol used by RabbitMQ has a headers table at the protocol level for user-defined key-value pairs that can be associated with the message payload. The same question applies here, what should go in this protocol header table vs on the message. One concern I have about using these user-defined headers is that in my designs I'll typically remove the p…
You could also place these user-defined headers in a special property of the message, e.g.:
{ // message object
"_headerTable": { … },
// actual message properties here
}
It is a common convention to use underscore-prefixed JSON properties for such meta data.