I was mulling over a use case that involved trying to bundle content that wasn't JSON inside the entities (just to minimize the chattiness of the API). For our purposes, image this is an image and we want to bundle it in a response. The question is, what is the best way to do it. The non-embedded version might look like:
"links": [
]
Now, if I wanted to embed things, I could use the data scheme, as such:
"links": [
{ "rel": [ "image" ], "href": "data:image/jpeg;base64,..." }
]
Seems simple. But I was wondering if it would be more consistent to put this under entities, e.g.,
"entities": [
{ "rel": [ "image" ], "href": "data:image/jpeg;base64,..." }
]
Or perhaps even better to include multiple links to give clients a chance to record the true URL for future reference.
"entities": [
{
"rel": [ "image" ],
"links": [
{ "rel": [ "data" ], "href": "data:image/jpeg;base64,..." }
]
}
]
Another possibility, which I don't like at all but would be interested if anybody advocates for it, would be:
"entities": [
{
"rel": [ "image" ],
"links": [
],
"properties": {
"content-type": "image/jpeg",
"data": "..."
}
}
]
Obviously, all are legal Siren. I'm just wondering if anybody sees any particular compelling pros and cons to any of these. Using "links" plus a single "data:" URI seems good enough to me. I'm just wondering if it is reasonable for clients to handle data: URIs seamlessly.
--
Mike