Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create templated link from param keys #9

Closed
wants to merge 1 commit into from
Closed

create templated link from param keys #9

wants to merge 1 commit into from

Conversation

schroedan
Copy link

This will add the params (if specified) on non-templated links.

@elmerbulthuis
Copy link
Member

Is this part of the HAL- standard?

@schroedan
Copy link
Author

I believe this is not part of the HAL spec. It just enables the hrefLink method to append the provided query params on non-templated links. Otherwise they would get lost.

@jbigman jbigman mentioned this pull request Aug 13, 2014
@pgaertig
Copy link

@pCoLaSD nice try. I suppose you just want to append some dynamic stuff like filtering by resource properties. However you PR restricts that only plain query params can be dynamically appended. Moreover you can't mix hash params, defined params with dynamic params or path parameters like the one below.

I would recommend to use what is already in spec and implemented by rfc6570.js. As an example, run the following line in the browser console on a page with angular-hal.js loaded:

new rfc6570.UriTemplate("http://localhost/api/{bucket}/items{?sort,filters*}").
    stringify({
        bucket: 'stuff',
        filters: {type: 'music', author: 'davidbowie'},
        sort:'created_at'});

Result: "http://localhost/api/stuff/items?sort=created_at&type=music&author=davidbowie"

Read the spec, there are even more cool use cases: http://tools.ietf.org/html/rfc6570

@schroedan
Copy link
Author

@pgaertig thank you for this advice. The actual problem I have ist that my PHP backends (implemented with Zend Framework 2 and some Apigility magic) can't handle templated links. In consequence I can't "stringify" those links out of the box in my app.
I think it will be a better approach to teach Apigility to handle templated links instead of this litte hack here.
Thanks anyway!

@schroedan schroedan closed this Aug 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants