PDA

View Full Version : CodeIgniter and RESTful stores



Thomas Triplet
6 Aug 2010, 7:41 AM
Hi,
Most MVCs, CodeIgniter in particular, are based on URI of the form http://base_url/controller/function/param1/param2/...

So instead of DELETE, PUT, GET requests, I'd the store to send request like this:

base_url/my_controller/create
base_url/my_controller/delete/5
base_url/my_controller/update/id/5/field/newFieldValue
base_url/my_controller/get/start/0/limit/50/queryField/fieldValue


I tried to setup the store's restful param to true, but it didn't help. Any suggestion?

Condor
7 Aug 2010, 4:04 AM
Configuring the store with an api and restful:true should already generate the first 2 urls you mention.

The last 2 are not supported by default and would require you to write your own buildUrl method.

Thomas Triplet
7 Aug 2010, 6:44 PM
Thanks Condor. Sorry if this sounds like a stupid question, but I haven't found buildUrl(). I was thinking of using setUrl() (or setApi() ) in the request() method of the HttpProxy. Is that a valid approach or is there a better way to do this? I'm guessing I could also create my own proxy by extending the HttpProxy

Condor
7 Aug 2010, 11:33 PM
The easiest method is probably to use setUrl from the beforeload/beforewrite event.