In my custom APEX REST endpoint, I want to have the exact same pagination as the SFDC REST API. Is there an easier way to achieve this than implementing the logic from scratch? I would love to just extend abstract base class that holds all this logic and is used by the SFDC REST API as well. Or something similarly convenient, that doesn't involve me re-inventing the wheel.
Thanks in advance, Peter