Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Link Headers can be used to add relations to a message independent of the format used. For example, Link: <http://ex.org/rest/types/node/article>; rel="type"
Currently, there is no way to access the information from those headers once you are serializing/deserializing a request.
Proposed resolution
In RequestHandler, extract the Link headers from the request and pass them in to the Serializer using the $context.
Some examples 5.5. Examples
Comments
Comment #1
clemens.tolboomPlease add some example use cases. Why would one want to 'inject' links? What client needs are resolved by this?
What 'steps to reproduce' are needed? Preferably a curl command.
Sound trivial to build right?
Slightly related #1964034: Pass entity_type into Serializer via context
Comment #2
Crell CreditAttribution: Crell commentedLink relationships are fundamental to HATEOAS/REST semantics. Various body formats like HAL have ways to define those link relationships. There's also an IETF RFC to specify them as an HTTP header. That's what this issue is asking about.
Comment #3
clemens.tolboomAdded link to https://tools.ietf.org/html/rfc5988#page-6 and https://tools.ietf.org/html/rfc5988#page-9
Comment #4
Crell CreditAttribution: Crell commentedActually, looking this over again I'm not sure I understand it. Lin, which headers are you talking about passing in...? I can absolutely see us *generating* Link headers, but consuming them doesn't really make sense. We're not consuming HAL at all (which has links), just generating. Can you even have Links in a Request message?
This is probably 8.1.x material now, too.
Comment #5
Wim LeersIt sounds like this is also about using Serializer context, #1964034: Pass entity_type into Serializer via context and #2568413: REST views: Pass views style plugin instance to REST Export serializer are too.
Comment #9
Wim Leers#4 wrote almost 2.5 years ago that he didn't understand it.
And now that #2854830: Move rest/serialization module's "link manager" services to HAL module moved the existing link manager from the REST module to the HAL module where it belongs (because all of it is entirely coupled to the HAL normalization), this is also something that would clearly belong in the HAL component.