-
Notifications
You must be signed in to change notification settings - Fork 651
Audit link relations #1139
Description
Links were always intended to follow the IANA link relations registry, but we accidentally broke this in v2 by using taxonomy slugs directly as relations.
Let's fix these up, and also rethink our approach. Rather than using custom link relations, we can restructure to match the way that Atom/RSS/etc feed discovery works by including a type parameter.
For example, rather than Link: <.../meta>; rel=<http://wp-api.org/2.0/meta>, we can do Link: <.../meta>; rel=related; type=<http://wp-api.org/2.0/meta>
Old-style in JSON:
{
"_links": {
"http://wp-api.org/2.0/meta": [ {
"href": ".../meta",
} ]
}
}New-style in JSON:
{
"_links": {
"related": [ {
"href": ".../meta",
"type": "http://wp-api.org/2.0/meta",
} ]
}
}This should make indexing into it easier (_links.related[0].href), and allows us to be more flexible too. For example, something like Pods could also expose Link: <.../pods/42/fields>; rel=related; type=<http://pods.io/1.0/fields/> and have it grouped alongside.
(Props @rachelbaker for inspiring this.)