CodeIgniter Forums

Full Version: about API Response Trait
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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/codeig...restserver 
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...stful.html
(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
Both of those links are giving me an 404 Error page at 6:24 pm EST.
(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.
(09-04-2019, 03:21 PM)ciadmin Wrote: [ -> ]https://codeigniter4.github.io/userguide...stful.html

Thx!! ... 

PS: Both link on the first reply are 404 to me too!
@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...stful.html
Thanks ciadmiin.