[LRUG] REST and Associations
Ben Lund
ben at benlund.co.uk
Fri Feb 23 02:18:05 PST 2007
Hi,
Andrew Stewart wrote:
>> 2. What is the right way to do search? Are query strings still ok in
>> urls? Is search a seperate controller?
>
> I don't know about the 'right' way, but this is how I think of it:
>
... stuff about detectives
Marvelous!
To (over-)extend your analogy to the question of whether /posts/1;edit
is really RESTful: Imagine that instead of getting a new warrant, the
detectives just wanted to modify the old warrant to include the garden,
and then re-do the entire search.
Perhaps the judge has a form for just such occasions? So the detectives
GET the form for editing from him, fill it in, and submit it. In an
ideal world, they would just PUT it in his hands, but he works from
home, so they have to POST it to him. In any case, he responds by
telling them where they can GET their new warrant.
So I tend to think of edit as being fully RESTful.
>> Is the idea that *exactly* the same resource(s) are
>> returned, no matter the mime type or can _what_ is returned vary as
>> well as _how_ it is returned?
>
> I believe that exactly the same resources should be returned,
> regardless of MIME type. In this case you have two queries: all and
> recent.
I'm not so sure about that. Remember that REST stands for
REpresentational State Transfer, and that what you send out over the
network are different representations of the same underlying resource.
That resource could be something a bit fuzzy like "a collection of some
recent foo-things".
So I tend to think that it's OK for the application/xml representation
to list all entries in a collection, while the application/xhtml+xml
representation lists only some, but with links to the rest. After all,
the XHTML representation is going to have extra things in it that the
XML won't (like links to log-in forms and so on), so they don't have to
list exactly the same resources.
Ta,
Ben
--
For Work: http://www.benlund.co.uk/
For Play: http://benlund.info/
"Sorry to see that you've had the British workman in the house."
- Sherlock Holmes in 'The Crooked Man'
More information about the Chat
mailing list