Open mikaa123 opened 10 years ago
something along these lines:
halRepresenter(function (hal, entity) {
var res = {};
hal.links(res, [
aResource, // Use the resource's name for rel, and the resource's path
{ 'rel': anotherResource } // Custom rel
]);
hal.embedded(res, { posts: posts });
return res;
});
Or even simpler:
halRepresenter(function(res, entity) {
res.attributes({
'count': 3
});
res.embedded({
'users': ['foo']
});
res.links({
'bar': 'baz'
});
})
I <3 HAL and I use it a lot. Instead of having to manually create "links" and "embedded", it could be useful to have a representation strategy for it.