I am using codeigniter to create a restapi and I am having some problems with routes.
Here is the equation:
I have to navigate /users/
to index function,
I have to navigate /users/{MongoId}
to /users/show/{MongoId}
,
I have to navigate /users/function
to /users/function
.
And here, my routes:
$route['api/users/do_login'] = "api/users/do_login";
$route['api/users/(.*)'] = "api/users/show/$1";
When I remove the (.*)
routing (or both of them), my do_login function works successfully. But not my api-index function because Codeigniter takes MongoId as function name and fails.
When I write it back (or both), my index function works successfully, but my login doesn't. Because it tries to send function name to show function as parameter.
Can you please help me to fix that?
Here, the working routes.
$route['api/users/do_login/(:any)'] = "api/users/do_login/$1";
$route['api/users/(:any)'] = "api/users/show/$1";