Paginating Lists
This commit is contained in:
@@ -23,6 +23,14 @@ func ValidateFilters(v *validator.Validator, f Filters) {
|
||||
v.Check(validator.PermittedValue(f.Sort, f.SortSafelist...), "sort", "invalid sort value")
|
||||
}
|
||||
|
||||
func (f Filters) limit() int {
|
||||
return f.PageSize
|
||||
}
|
||||
|
||||
func (f Filters) offset() int {
|
||||
return (f.Page - 1) * f.PageSize
|
||||
}
|
||||
|
||||
// sortColumn : Check that the client-provided Sort field matches one of the entries in our safelist and if it does, extract the column name from the Sort field by stripping the leading hyphen character (if one exists)
|
||||
func (f Filters) sortColumn() string {
|
||||
for _, safeValue := range f.SortSafelist {
|
||||
|
||||
Reference in New Issue
Block a user