Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Audit link relations #1139

@rmccue

Description

@rmccue

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions