0

I am creating the REST API using codeigniter. I downloaded this library and installed in my application. It works great! https://github.com/chriskacerguis/codeigniter-restserver

But I have an doubt. As per this library. I have 4 functoins

  1. GET
  2. POST
  3. PUT
  4. DELETE

I understand the functionality of each POST method but what I concern is how to write the validation and other things in the REST API.

Example: I have created the controller User.php

class User extends REST_Controller {

     public function __construct() 
     {
        parent::__construct();               
     }

     // Get multile / individual users records and perform search also.
     public function index_get()
     {  
         $this->response('get / search users', REST_Controller::HTTP_OK);
     }

     // User Registration / Login
     public function index_post()
     {   
         echo 'create';
     }

     // User Information Update
     public function index_put()
     {
         echo 'update';
     }

     // User Delete
     public function index_delete()
     {
         echo 'delete';
     }    
}

I tested in postman post method works fine.

Here is my question. I have the following functionality for user.

  1. Register
  2. Login
  3. Forgot Password
  4. Change Password
  5. Update Profile

I think except Register other functions are posted with PUT method? In the PUT / POST method do I have to write all validations and database operation buy identity the post method variable using action likes register, login, forgot-password etc.,

In admin I want to get active or inactive users, find by email or name. this kind of operations where we have to write?

Thanks to all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.