Search the web
Sign In
New User? Sign Up
rest-discuss · REST Discussion Mailing List
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Using HTTP Link: headers for web linking non-hypertext   Message List  
Reply | Forward Message #13064 of 14417 |
Re: [rest-discuss] Using HTTP Link: headers for web linking non-hypertext





Sam Johnston a écrit :

> Does this not strike you as far more complicated than necessary? Under
> your proposal I need to do a bunch of requests and understand a new
> language just to work out that two resources are related.

Indeed, this is a little overhead since here I modeled a one-to-many (or
many-to-many as suggested before) relationship, and added more semantic
than necessary here for example, implying the use of RDF, which is IMO
the better approach to represent metadata for and links between
resources. A more simple approach could use text/uri-list [RFC2483] as
media type for the representation of the resource containing the
relations (i.e. a simple uri...) as in

===============
GET /buildings/1234
Accept: image/jpeg
----------
200 OK
...
(jpeg representation of the building)
==============
GET /buildings/1234
Accept: text/uri-list

200 Ok
...

http://www.example.com/architects/spamegg
==============

granted that it is a one-to-one relation and there is no ambiguity on
the link semantic (as with Link header).

The main point is that the link is itself a (sub)resource (or an
alternate representation) of the initial resource and can therefore be
manipulated directly using existing methods

=============
PUT /buildings/1234
Content-Type: text/uri-list

http://www.example.com/architects/foobar
=============

> The Link: header accomplishes the same job in a far simpler and more
> performant manner, only until now no mechanism (beyond the HTTP LINK and
> UNLINK verbs) has been specified for creating them.

> Therein lies the question... what is the most intuitive way to associate
> resources? Given the relationships are exposed via HTTP headers one
> would assume that the same mechanism could/should be used to manage them.

As stated in Roy thesis (if I'm right), every piece of information that
can or should be manipulated by the UA must be a resource by itself.

Moreover, this approach allow many-to-many relations (not talking about
several kinds of semantic relations) to be represented and manipulated
in the same homogeneous way as simple non ambiguous unique links


> On Wed, Jul 1, 2009 at 11:48 AM, Yannick Loiseau <yloiseau@...
> <mailto:yloiseau@...>> wrote:
>
>
>
> I agree with mike.
> IMHO, it seems it is here a meta level problem w.r.t. the application
> vs. protocol POV.
> Taking the building/architect example, the architect of a building is a
> metadata for the application (information about the building). But as
> long as the UA needs to manage this information (read/edit), it should
> be a resource by itself, i.e. data at the protocol level. The fact that
> this metadata can't be embed in one of the representations of the
> building resource (e.g. an image) just imply the need for another
> representation (conneg is your friend), not that this information
> pertains to HTTP headers. RDF was just design for this use case:
> provide
> external metadata about resources that can't embed them. Turtle or N3
> can be used for xml reticents, or just a custom key:value format (but
> don't reinvent the wheel :)
> Metadata being a resource, they can be easily edited (using POST, PUT,
> PATCH, or lower granularity (sub)resource manipulation).
>
> example (turtle not tested)
> ==============
> GET /buildings/1234
> Accept: image/jpeg
> ----------
> 200 OK
> ...
> (jpeg representation of the building)
> ==============
> GET /buildings/1234
> Accept: text/turtle
> ---------
> 200 Ok
> ...
>
> @prefix rel: <http://www.example.com/relations/ns#> .
> @prefix dc: <http://purl.org/dc/elements/1.1/> .
> @prefix ent: <http://www.example.com/entities/ns#> .
>
> <http://www.example.com/buildings/1234>
> a ent:building ;
> dc:title "A nice building";
> rel:architects <http://www.example.com/buildings/1234/architects;
> ==============
> GET /buildings/1234/architects
> Accept: text/turtle
> ----
> 200 Ok
>
> @prefix ent: <http://www.example.com/entities/ns#> .
>
> <http://www.example.com/buildings/1234>
> ent:Architect <http://www.example.com/architects/spamegg> .
>
> ==============
> POST /buildings/1234/architects
> ...
>
> http://www.example.com/architects/foobar
> -------
> 201 Created
> ...
>
> @prefix ent: <http://www.example.com/entities/ns#> .
>
> <http://www.example.com/buildings/1234>
> ent:Architect <http://www.example.com/architects/foobar>,
> <http://www.example.com/architects/spamegg> .
> ===============
> GET /architects/foobar
> Accept: text/turtle
> ------
> 200 Ok
>
> @prefix ent: <http://www.example.com/entities/ns#> .
> @prefix rel: <http://www.example.com/relations/ns#> .
> @prefix foaf: <http://xmlns.com/foaf/0.1/> .
>
> <http://www.example.com/architects/foobar>
> a foaf:Person ;
> foaf:name "Foo Bar";
> rel:hasBuilt [
> <http://www.example.com/buildings/1234> ;
> <http://www.example.com/buildings/5678> ;
> ] .
>
> If the list of buildings for an architect needs to be manipulated, the
> same pattern can be used, creating a /architects/foobar/buildings
> resource, using HATEOAS...
>
>
>
> >
> > FWIW, Link *Headers* make sense to me when the link are metadata
> about
> > the resource. However, when the links are to be treated as
> first-class
> > resources themselves, I think Link Headers is not the right
> choice. For
> > example, I assert that links appearing in the <head /> section of
> > typical HTML documents are metadata. Links that appear in the
> <body />
> > section are not.
> >
> > I am not privy to the details of your particular use of links,
> but I get
> > the impression that they are more than metadata. If true, I would
> > consider placing the links either in the body of the resource or,
> when
> > the resource does not support body links easily (certain binary
> files,
> > etc.), I would add a single link header (Link:
> > <http://www.example.org/resource123/links>; rel=related) that
> points to
> > the related resource that holds all the links. One possible
> advantage of
> > this approach is that the related links are now exposed in a way
> that
> > easily allows searching and filtering using well-established
> mechanisms.
> >
> > Also, this sentence from your last post caught my eye:
> > <snip>
> > It's unavoidable (I think) that a case in which you might simply
> add a
> > foreign key or a bridge table when thinking relationally, you
> need to do
> > lots of contortions to do RESTfully.
> > </snip>
> >
> > This is very true. For me, that's an excellent reminder that the
> > relational approach is not the same as a RESTful approach.
> >
> > mca
> > http://amundsen.com/blog/
> >
> >
>



Wed Jul 1, 2009 3:37 pm

pioupiougroups
Offline Offline
Send Email Send Email

Forward
Message #13064 of 14417 |
Expand Messages Author Sort by Date

... They (browsers) do not. But that is besides the point for this thread. The key question being debated is whether link management is a client concern or it...
Subbu Allamaraju
sallamar
Online Now Send Email
Jul 1, 2009
4:37 pm

... Ok so here's a separate but similar issue. I've just released an Internet-Draft...
Sam Johnston
sam.johnston...
Offline Send Email
Jul 1, 2009
11:18 pm

... The point is you don't have to be able to create links to consume them and vice versa. Both servers and clients create links and there seems little point...
Sam Johnston
sam.johnston...
Offline Send Email
Jul 1, 2009
4:35 pm

Hi Subbu- ... This looks just right for a one-many link (as in my #1 option -- post to a cart "collection" resource) in which the "one" is obvious and easily ...
Peter Keane
pkeane_littl...
Offline Send Email
Jun 30, 2009
8:29 pm

Peter, ... This is a great use case - thanks a lot. ... I'm going one step further in eliminating the Atom for individual resources. That would allow you...
Sam Johnston
sam.johnston...
Offline Send Email
Jun 30, 2009
8:50 pm

... So, when you let clients establish links between resources, who controls whether a link is valid or bogus? What is the advantage of the client owning this...
Subbu Allamaraju
sallamar
Online Now Send Email
Jun 30, 2009
10:26 pm

... Good questions. Certainly, it'll be the server that controls what's a valid "linkage", but the range of possibilities might be (nearly) infinite. And I ...
Peter Keane
pkeane_littl...
Offline Send Email
Jul 1, 2009
1:33 am

FWIW, Link *Headers* make sense to me when the link are metadata about the resource. However, when the links are to be treated as first-class resources ...
mike amundsen
mamund
Offline Send Email
Jul 1, 2009
3:02 am

I agree with mike. IMHO, it seems it is here a meta level problem w.r.t. the application vs. protocol POV. Taking the building/architect example, the architect...
Yannick Loiseau
pioupiougroups
Offline Send Email
Jul 1, 2009
9:49 am

Yannick, Does this not strike you as far more complicated than necessary? Under your proposal I need to do a bunch of requests and understand a new language...
Sam Johnston
sam.johnston...
Offline Send Email
Jul 1, 2009
1:46 pm

... Indeed, this is a little overhead since here I modeled a one-to-many (or many-to-many as suggested before) relationship, and added more semantic than...
Yannick Loiseau
pioupiougroups
Offline Send Email
Jul 1, 2009
3:38 pm

... Do you mean like this? GET /cart "cart" : {... , "products": [], .... } adding products: PUT /cart "cart": {..., "products": [ "/products/143",...
Mike Kelly
pleb1985
Offline Send Email
Jul 1, 2009
2:24 pm

... Mike- Yes, that's basically what I was proposing. (I was thinking specifically in terms of Atom, but the GET/EDIT/PUT pattern is exactly the approach I...
Peter Keane
pkeane_littl...
Offline Send Email
Jul 1, 2009
4:28 pm

... Let's leave aside the issue on whether to introduce LINK and UNLINK. What about the value of Link headers themselves? I really like the idea of...
Bill Burke
patriot1burke
Offline Send Email
Jul 1, 2009
12:26 pm

What is "polluting" about links? I suspect that you are talking about adding links to an object serialized into XML is polluting the representation. But is...
Subbu Allamaraju
sallamar
Online Now Send Email
Jul 1, 2009
1:09 pm

Subbu, I'm thinking more of the case where you have more generic services that need to know about certain relationships but don't understand the data format. ...
Bill Burke
patriot1burke
Offline Send Email
Jul 1, 2009
1:41 pm

Exactly - it's about making non-hypertext resources first class citizens on the Internet in an intuitive, RESTful manner. Sure I could base64 encode them and...
Sam Johnston
sam.johnston...
Offline Send Email
Jul 1, 2009
1:57 pm

I'm thinking even for hypertext-based resources you'd want link headers. Headers seem much much more simpler than requiring a envelope format like Atom. ... --...
Bill Burke
patriot1burke
Offline Send Email
Jul 1, 2009
2:10 pm

Ah. That makes sense. (To fully take advantage of these headers and entity headers in general, client APIs will need to start including headers as part of...
Subbu Allamaraju
sallamar
Online Now Send Email
Jul 1, 2009
2:31 pm

... Ditto - the question was about devising a "means to manage the implied relationship". The designers of HTTP planned to do it with LINK and UNLINK, but I...
Sam Johnston
sam.johnston...
Offline Send Email
Jun 26, 2009
1:29 pm

... Its not just about raw performance though. There's also a barrier to entry problem very similar to SOAP and CORBA. Before I heard about Atom, one of the...
Bill Burke
patriot1burke
Offline Send Email
Jun 26, 2009
2:39 pm
 First  |  |  Next > Last 
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help