lundi 30 août 2021

Recursion - should the Package/Library do it, or the user?

So to give further context; I am creating a Golang package/module to front a REST API.

The rest API does pagination and page sizes.

As the module creator, I obviously want to return the results. Should I create a return all function which recursively goes through all pages and return the complete dataset, or essentially mimic then REST API and offer a function where the user passes the page number and limit, and they then create a recursive function on their end.

I've looked at the UNIX design philosophy and while there is no clear answer, it looks like I should lean towards providing a basic function, and letting the user create the recursion.

I would appreciate any input/opinions - thanks in advanced.

Aucun commentaire:

Enregistrer un commentaire