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.

See 5. The Link Header Field

Some examples 5.5. Examples

Comments

clemens.tolboom’s picture

Title: Pass Link headers in to Serializer » Pass Link headers into Serializer
Category: Task » Feature request
Issue summary: View changes
Issue tags: +Novice
Related issues: +#1964034: Pass entity_type into Serializer via context

Please 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

Crell’s picture

Link 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.

clemens.tolboom’s picture

Crell’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Active » Postponed (maintainer needs more info)

Actually, 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.

Wim Leers’s picture

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Wim Leers’s picture

Component: rest.module » hal.module
Status: Postponed (maintainer needs more info) » Closed (works as designed)
Issue tags: -Novice
Related issues: +#2854830: Move rest/serialization module's "link manager" services to HAL module

#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.