Skip to content

Instantly share code, notes, and snippets.

@kborchers
Created January 17, 2013 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kborchers/4558860 to your computer and use it in GitHub Desktop.
Save kborchers/4558860 to your computer and use it in GitHub Desktop.
I'm pulling the conversation from IRC to this thread as I'm not sure if I'm explaining my issue with offset/limit properly.
Basically, my concern is we can not choose one between offset/limit and page/perPage. The client libraries need to support both as both are popular server-side paging implementations. We also can't just use one of those names and have it work both ways since that would be confusing to developers.
My suggestion is to name these two parameters something more generic like locator/count where locator=page/offset and count=limit/perPage. Then in our configs we would provide these options:
pagingType {String} - determines the paging method to be used in calculating next page, etc. and could be either "offset" or "page", default "offset"
locatorParam {String} - locator parameter name, default "offset"
locatorValue {Number} - page index or offset
locatorIdentifier {String} - the locator identifier name, default "AG-Paging-Offset"
countParam {String} - count parameter name, default "limit"
countValue {Number} - items per page
countIdentifier {String} - the count identifier name, default "AG-Paging-Limit"
Thoughts?
@secondsun
Copy link

I think that adding more config params may not be the best way to go about the solution to this problem.

Perhaps we need the ability to set a function which will consume {limit:int, offset:int} and apply the appropriate headers and query params to the current request.

wdyt?

@kborchers
Copy link
Author

@secondsun Not sure I follow. I only added one param to the config and then renamed the ones we've already decided on.

Not sure how your function idea would work without the config I mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment