CodeIgniter Forums
Customizing ResourceController Routes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Customizing ResourceController Routes (/showthread.php?tid=80027)



Customizing ResourceController Routes - rafinhaa - 09-03-2021

I have this controller:

PHP Code:
class Auth extends ResourceController
{    
    
protected $format    'json';

 public function 
__construct(){
 }
    public function login(){        
        
die('login');
    }
    public function logout(){
        die('logout');
    }





There's a way to create a route using $routes->resource, for example (or some way to create a similar one):
PHP Code:
$routes->resource('api/v1/auth', [
'post' => 'Api\V1\Auth::login',
'get' => 'Api\V1\Auth::logout',
]); 

Another question...

If I have other methods within my ResourceController, how can I customize these routes?
Ex: I already have a ResourceController Groups and the route $routes->resource('api/v1/groups');
But this controller has two more methods listUsersGroups and listGroupsPermissions, how can I add these new routes in my $routes->resource('api/v1/groups');

Thank you all