W3C home > Mailing lists > Public > public-hydra@w3.org > January 2015

Re: Using an IriTemplate with a class or property

From: <tomasz@t-code.pl>
Date: Sat, 03 Jan 2015 22:27:19 +0000
Message-ID: <4441c9d8e961aedf140108684c99d4f2@rainloop.t-code.pl>
To: "John Walker" <john.walker@semaku.com>, public-hydra@w3.org
Hi John

AFAIK templates are used to allow the client to build request URI but by using the user's input. A generic client would generate an appropriate form with fields for template variables. In the case you describe the server has all the necessary information required to build the URI and I would expect them to be included in a resource's representation.

I understand your reasoning though. However I'm quite undecided whether I agree or not. The tradeoff here is that less code is required on the server but more on the client. The problem is that you would effectively deny access to part of your API to clients, which don't process Hydra at all such as crawlers or simple Linked Data browsers.

Bottom line is it would an anti-goal, because such templates would mix two distinct functionalities. I'm not saying I don't like the idea. I fact I had similar though at some point. But it should be something different from the current IriTemplate IMO.


December 31 2014 5:34 PM, "John Walker" <john.walker@semaku.com> wrote: 
> Hi All,
> After having played about the past days making a JSON-LD wrapper for an existing API, it seems that
> alot of what I'm doing is related to IRI templates.
> Is there any way that a hydra:IriTemplate can be linked to a class or property to allow the client
> to figure out what is the next request to make?
> As an example here is the JSON-LD for a thing:
> http://breweryld.semaku.com/beer/CTKv9o
> Which was built from this original JSON:
> http://breweryld.semaku.com/beer/CTKv9o?json
> So for example I would define a template like this for the beer:
> http://breweryld.semaku.com/beer/{id}#id
> This would be linked to the Beer class and a client would know how to build the URI by populating
> the template with the data at hand, in this case the value of the id key.
> Similarly I might define a template like this for a style:
> http://breweryld.semaku.com/style/{styleId}#id
> This template can be linked to the styleId property and that the client would know how to build the
> URI based on the property value.
> Putting this logic in the Hydra client would help having to implement similar logic on server side
> in many APIs.
> Regards,
> John Walker
> Principal Consultant & co-founder
> Semaku B.V.
> SFJ 4.009, Torenallee 20, 5617 BC Eindhoven
> Mobile: +31 6 475 22030
> Email: john.walker@semaku.com
> Skype: jaw111
> KvK: 58031405
> BTW: NL852842156B01
> IBAN: NL94 INGB 0008 3219 95
Received on Saturday, 3 January 2015 22:28:01 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:29:44 UTC