Re: How to differentiate between multiple Operations which use the same HTTP Action

On 04/23/2014 05:52 PM, Markus Lanthaler wrote:
> On Wednesday, April 23, 2014 4:38 PM, Thomas Hoppe wrote:
>> Hi,
>>
>> think about the following use-case: You have a collection and you have
>> the implicit GET based operation to retrieve the  the collection
>> itself (the one we are discussing in parallel is not required to have
>> a named operation for, Issue #11). Now you want to offer a second
>> operation which allows querying the collection with some complex
>> syntax that you don't want to serialize in the query string (maybe it
>> is  too complex to be expressed as URI template). Therefore you define
>> the operation such that it expects a query object:
>>
>> ...
>> operation: [
>> {
>>      @type: "http://example.org/QueryOperation",
>>      method: "GET",
>>      expects: "http://example.org/classes/Query"
>> }
>>
>> So on the server side you are forced to distinguish two GET based
>> requests. The only way is to consider the request body.
> Uuhhh... I would really urge you to use a different method. You will
> probably run into heaps of problems if you use a GET with a request body
> (even though it is not explicitely disallowed). Why don't you use a PUT
> instead?
I know that it is very uncommon, but we should have
this discussion, just to illuminate another edge case.
Generally speaking I think the state of the current REST API querying is 
pretty undeveloped yet
if we take RDBMS as benchmark of what should be possible.
There should be a common practice (which is not related to hydra) for 
the case,
no matter what querying language you use.
Although theoretically possible, using PUT does not feel natural for 
data querying I think.

>
> In any case, from the point of Hydra is doesn't really matter what method
> you use. The semantics are expressed by the operation's type (in this case,
> QueryOperation). The server doesn't see that so it has to "reconstruct" the
> intention by looking at the request URL and body, as you say.
>
Ok, great that we came to the same conclusion about this.

Received on Wednesday, 23 April 2014 18:33:00 UTC