I created a controller named Api.php then I extended the Rest_Controller. I noticed that I can only use index_get() when creating a function in this controller
<?php
class Api extends REST_Controller{
public function __construct()
{
parent::__construct();
}
public function index_get(){
$car_id = $this->get('car_id');
if(!$car_id){
$this->response("No Car ID specified", 400);
exit;
}
$result = $this->model_getvalues->getCars( $car_id );
if($result){
$this->response($result, 200);
exit;
}
else{
$this->response("Invalid Car ID", 404);
exit;
}
}
}
but when I try creating my desired function like getAllCars() instead of index_get() I get an error message telling me unknown function.
How can I define my own function instead of using index_get() when using rest api library in CodeIgniter?
_getsuffix already in there just name your methodcars_get()and if you've a post request you can call your methodcars_post()- but from outside its always the same namely/cars//cars/?id=123?