Welcome Guest, Not a member yet? Register   Sign In
RESTful server with CI
#5

[eluser]Phil Sturgeon[/eluser]
If you have a site that mixes standard web output with an API in there too, you will want to call your controller something like api.php or order_api.php. If you are REST only then call it orders.php

Then your REST calls could be:

order/id/563456

This would match up to:

Code:
function order_get()
{
    $id = $this->get('id');
}

You dont need to use put unless you plan on using cURL to add new orders. Most wont need to do this and you can always use POST to achieve the same result which works from the browser too.

In my example, users_get means get multiple users. user_post means get a single user and user_post means update a single user.

Notice the use of plural and singular to give different meaning, combined with the HTTP Request Method to show what we are doing with it.

You can name a call /orders/do_something_totally_mental/something/df453 if you like, it really doesn't matter as long as your method is "function do_something_totally_mental_get()".


Messages In This Thread
RESTful server with CI - by El Forum - 07-01-2009, 03:39 AM
RESTful server with CI - by El Forum - 07-01-2009, 04:42 AM
RESTful server with CI - by El Forum - 07-01-2009, 10:09 AM
RESTful server with CI - by El Forum - 07-01-2009, 11:41 AM
RESTful server with CI - by El Forum - 07-02-2009, 04:13 AM
RESTful server with CI - by El Forum - 07-07-2009, 08:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB