CodeIgniter Forums
about API Response Trait - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forum-31.html)
+--- Thread: about API Response Trait (/thread-74112.html)



about API Response Trait - Martin_Salas - 07-23-2019

I was using tests in CI3, with the codeigniter-restserver library and I liked the following implementation:

class Books extends CI_Controller
{
  use REST_Controller {
   REST_Controller::__construct as private __resTraitConstruct;
 }
 public function index_get()
 {
   // Display all books
 }

 public function index_post()
 {
   // Create a new book
 }

public function index_delete($id)
{

  // Delete a book
}
}


What I like is that: the method names will be appended with the HTTP method used to access the request. If you're making an HTTP GET call to /books, for instance, it would call a Books#index_get() method.

Is it possible for CI4 to work this way?

link:  https://github.com/chriskacerguis/codeigniter-restserver 



RE: about API Response Trait - ciadmin - 07-23-2019

The intent is to have something that matches the HTTP verbs more closely.

That will find its way into the develop branch, hopefully before RC1. It might not be in exactly that form, but it should be close. We just need time and unit testing Undecided

EDIT: The links that were originally here referred to code that has since been merged. The RESTful stuff is described here... https://codeigniter4.github.io/userguide/incoming/restful.html


RE: about API Response Trait - Entai - 09-04-2019

(07-23-2019, 08:16 PM)ciadmin Wrote: The intent is to have something that matches the HTTP verbs more closely. **Obsolete links removed; see modified message above.**

That will find its way into the develop branch, hopefully before RC1. It might not be in exactly that form, but it should be close. We just need time and unit testing Undecided

Now with the release of the RC1 how I use the REST api??? where I can find info of that


RE: about API Response Trait - ciadmin - 09-04-2019

https://codeigniter4.github.io/userguide/incoming/restful.html


RE: about API Response Trait - InsiteFX - 09-04-2019

Both of those links are giving me an 404 Error page at 6:24 pm EST.


RE: about API Response Trait - ciadmin - 09-04-2019

(09-04-2019, 03:24 PM)InsiteFX Wrote: Both of those links are giving me an 404 Error page at 6:24 pm EST.

Very weird ... I see no problem here, and Cloudflare is not reporting anything.
I don't know what to suggest.


RE: about API Response Trait - Entai - 09-04-2019

(09-04-2019, 03:21 PM)ciadmin Wrote: https://codeigniter4.github.io/userguide/incoming/restful.html

Thx!! ... 

PS: Both link on the first reply are 404 to me too!


RE: about API Response Trait - ciadmin - 09-04-2019

@InsiteFX @Entai The links that were originally here referred to code that has since been merged; that is why they didn't work. The RESTful stuff is described here... https://codeigniter4.github.io/userguide/incoming/restful.html


RE: about API Response Trait - InsiteFX - 09-05-2019

Thanks ciadmiin.