Skip to content
This repository has been archived by the owner. It is now read-only.

Use short CURIEs instead of full URIs #1488

Closed
rmccue opened this issue Aug 20, 2015 · 9 comments

Comments

Projects
None yet
6 participants
@rmccue
Copy link
Member

commented Aug 20, 2015

One small annoyance in the API right now is that link relations are full URIs. In JavaScript, this means that while you have _links.self and _links.author, you have to do _links["http://v2.wp-api.org/term"]. This is a bit ugly, and can be confusing.

We should instead switch to CURIEs. These are an abbreviated form of the full URI that's easier to work with, but can be expanded out to the full URI if needed. They look like this:

{
    "_links": {
        "curies": [
            {
                "name": "wp",
                "href": "http://v2.wp-api.org/{rel}",
                "templated": true
            }
        ],

        "wp:term": [
            {
                "taxonomy": "category",
                "href": "..."
            },
            {
                "taxonomy": "post_tag",
                "href": "..."
            }
        ]
    }
}
@malfborger

This comment has been minimized.

Copy link

commented Aug 28, 2015

+1 !

@scottopolis

This comment has been minimized.

Copy link

commented Sep 18, 2015

+1

@rachelbaker rachelbaker added this to the 2.0 milestone Sep 23, 2015

@danielbachhuber

This comment has been minimized.

Copy link
Member

commented Nov 18, 2015

@danielbachhuber

This comment has been minimized.

Copy link
Member

commented Nov 18, 2015

Actually, I just realized this will only affect our endpoints.

@danielbachhuber danielbachhuber modified the milestones: 2.0 Beta 10, 2.0 Dec 13, 2015

@danielbachhuber danielbachhuber self-assigned this Dec 13, 2015

@danielbachhuber danielbachhuber removed this from the 2.0 Beta 10 milestone Dec 14, 2015

@danielbachhuber

This comment has been minimized.

Copy link
Member

commented Dec 14, 2015

We should handle this magically in the server: https://core.trac.wordpress.org/ticket/34729

@danielbachhuber danielbachhuber added this to the 2.0 Beta 11 milestone Jan 12, 2016

@danielbachhuber danielbachhuber removed their assignment Jan 12, 2016

@danielbachhuber

This comment has been minimized.

Copy link
Member

commented Jan 12, 2016

Re-opening, because we need to add a shim to the plugin when the server code lands.

@danielbachhuber

This comment has been minimized.

Copy link
Member

commented Feb 16, 2016

@rmccue @joehoyle thoughts on how we can shim this into the plugin?

@joehoyle

This comment has been minimized.

Copy link
Contributor

commented Feb 19, 2016

So I've been looking into doing this, we don't have good hooks in place to modify the response links, best I can see is to either run a subclass of the server class in the plugin, or filter the server response and look for links recursively (bit of a hack).

@danielbachhuber

This comment has been minimized.

Copy link
Member

commented Feb 19, 2016

best I can see is to either run a subclass of the server class in the plugin

I think subclassing seems like the cleanest implementation at this point

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.