Sounds like the fingerprint, portrait, and scan could all be subordinate
resources. Maybe http://example.com/person/123 returns an HTML or XML document
with several links in it, like:
(excuse my not-exactly-Atom XML)...
<entry>
<id>http://example.com/person/123</id>
<link rel="http://example.com/schemas/#portrait"
href="http://example.com/person/123/portrait
type="image/jpeg"/>
<link rel="http://example.com/schemas/#fingerprint"
href="http://example.com/person/123/fingerprint"
type="image/jpeg"/>
...
</entry>
Etc.
Jon
________________________________________
From: Sam Johnston [mailto:samj@...]
Sent: Monday, July 06, 2009 2:27 PM
To: Moore, Jonathan (CIM)
Cc: Subbu Allamaraju; Jim Edwards-Hewitt; rest-discuss@yahoogroups.com
Subject: Re: [rest-discuss] Resources with read-only and read-write parts
On Mon, Jul 6, 2009 at 7:51 PM, Moore, Jonathan (CIM)
<Jonathan_Moore@...> wrote:
Well, the "[as is]" isn't actually part of the RFC.
Right, which is why I said "The way I read the RFC is..."
The body of the PUT request is simply a *representation* of the state.
Which brings me to a question I considered asking but didn't. REST talks about
representations of resources, where one resource can have multiple
representations.
Let's say I have a person (http://example.com/person/123) and instead of
transferring the person over HTTP (which is not yet possible) I make available
their portrait, fingerprint(s), a scan of their national ID card and some XML
demographics. Where I use distinct content types I can simply PUT a given
representation and have the server side state updated accordingly.
What's the best practice though when portrait, fingerprint and scan are JPGs?
That is, I'm retrieving http://example.com/person/123 with Accept: image/jpeg
but it's impossible to tell whether it's the portrait, fingerprint or scan I'm
after. Similarly, what if I want the fingerprint in PNG?
I immediately start thinking about putting the content-type and/or link-relation
into the URL:
http://example.com/person/123;rel=portrait;type=image/jpeg
Then I start to think about cleaning this up a bit:
http://example.com/person/123/portrait.jpg
But this requires routes/rules and doesn't seem as clean/flexible as it should
be.
Sam