Never mind, I just notice I would write optional parameter and its all working fine.
But its looks like as the sub-resources goes deeper, the logic within get_users will increasing as there is no way to separate the sub-resources into different function.
i.e.
/api/users/1/posts/1
Will be
public function get_users($userid = null, $subresource_dir = null, $subresource_id, $subresource_dir2, $subresource2_id ......)
If you want to keep the code in a single controller, you can also give your controller a router() method. It gets both the method called and the arguments, so you can use that to dispatch the request to different methods.