Description
Description
For our current API to adopt JADNC (using database tables that contain millions of rows), we need the capability to constrain the maximum page size. Combined with client-based rate limiting, this protects us from callers issuing requests for potentially enormous responses, resulting in timeouts and/or database slowdowns on our side.
And given there are performance issues with paging through large sets (SQL Server, Elasticsearch), we need to limit the maximum value for page number too.
To support these, I propose to add the next properties to IJsonApiOptions
:
- int? MaximumPageSize { get; }
- int? MaximumPageNumber { get; }
This enabled JADNC implementers to optionally set these in Startup
, and they will be applied to all resources. An exception in thrown (resulting in 400 Bad Request) when a higher value is specified in the query string.
I'm willing to start work on a PR to implement this. Please let me know if this fits with the project vision. I've seen #217, which proposes a maximum page size per resource. That may still be implemented at a later time too, as a more fine-grained way to control this. But I think having a fallback default like proposed here does not conflict with the earlier proposal.