You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As said in this thread on Twitter, I think this is a good idea. I'll probably won't get around to implement this soon, because I'm still working on the traversal continuation feature whenever I have time to work on Traverson. If somebody else wants to take a shot at this, a PR would be most welcome.
I don't fully understand the example given here, though - I think it's a bit incomplete? I'll try to make up a more complete example, just to make sure we are on the same page:
What we would like to do now is to fetch the first resource and use one of its attributes (for example, the value of the attribute agent_1, that is, "007") and feed this into the URI template agent_details to get to the resource at https://api.example.com/agents/007.
We need a way to tell Traverson about this. I don't think the follow method is what needs to change, this just tells Traverson which links are to be traversed, so in the example above it would still simply be follow('agent_details'). The proper place to tell Traverson about this is withTemplateParameters. It could look like this:
This is to be read as: "Whenever you resolve a URI template and it has a URI template parameter agent_id, don't use a fixed substitution value but look up the value in the last HTTP response and use the value of the attribute agent_1. It would be nice if key could also be a JSONPath expression. The reason for the lookupStrategy thing: In future, we might conceive other sources for template substitution values.
basti1302
changed the title
Allow usage of a response body as URI templates
[feature-request] Allow usage of a response body as URI templates
Feb 1, 2016
I would like to be able to use a response body as template parameters further down the chain.
An example api could be
Where `self' returns:
and clients == 'http://host/agents/{agent_id}/clients'
The text was updated successfully, but these errors were encountered: