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

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

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions