ZF-7896: Does zend_rest_route respect RESTful protocol stand
Description
Hi, from my understanding of RESTful protocol, the server side is supposed to accept a request like this: /REST/1 It should also be able to interpret /REST/?id=1 or /REST/type="x"
In the current implementation however we can only do the first kind of url. Is it up to us to test for is sent and act accordingly? JR
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2009-09-19T09:21:36.000+0000
Typically, ReST says that there should be a single URI for any given resource, and that it should be returned in the Location header on successful creation. While it may be useful to support both styles, it would also add significant complexity for very little benefit.
Luke, any thoughts on this?
Posted by Luke Crouch (lcrouch) on 2009-09-19T17:04:50.000+0000
You should already be able to send a request like:
/REST/?id=1
If that's not working, it's a bug and I'll fix it.
As for the other URI, it could (and probably should?) be expressed:
/REST/type/x
I'd like to see the context for an identifier like /REST/type="x". I've never seen query params supplied like that without a '?' character in a URI.
Posted by jean-rubin (jrleonard) on 2009-09-20T04:16:41.000+0000
In the case you have a table like ID name type 1 bar type1 2 baz type2 3 foo type2 4 bat type1
/rest/1 should give you the data pertaining to the row with id 1 and so on. /rest/?id=1 should give the same as /rest/1 but currently that doesn't work (I have build 18038)
/rest/?type=2, which I figure should return 2 baz type2 and 3 foo type2 doesn't work either but I suspect it might not be RESTful. I was just looking for confirmation. JR
Posted by Luke Crouch (lcrouch) on 2009-09-22T09:51:42.000+0000
Ah, in that case if you want to return more than one resource, Zend_Rest_Route and Zend_Rest_Controller are designed to do so like this:
/rest/index/type/type2
Which will route to RestController::indexAction() with type=>type2 parameter, which you can then use to query the DB where type = 'type2' and go from there.
I'll recreate a test for the /rest/?id=1 and try to get that fixed. In the meantime, try using /rest/1
Thanks, -L
Posted by Luke Crouch (lcrouch) on 2009-12-30T10:49:08.000+0000
Fixed support for ?param=value query param values.