Skip to content

Commit

Permalink
move pagination scheme validation to init phase
Browse files Browse the repository at this point in the history
  • Loading branch information
briskt committed Jan 22, 2025
1 parent 55dfbbb commit 6f4b7d2
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions restapi/restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,6 @@ func (r *RestAPI) listUsersForPath(
return
}

if scheme != PaginationSchemeItems && scheme != PaginationSchemePages {
msg := fmt.Sprintf("invalid pagination scheme (%s), must be %s or %s",
r.Pagination.Scheme, PaginationSchemeItems, PaginationSchemePages)
log.Println(msg)
errLog <- msg
return
}

batchCounter := 0
for i := r.Pagination.FirstIndex; i <= r.Pagination.PageLimit; i++ {
nextIndex := i
Expand Down Expand Up @@ -494,6 +486,10 @@ func (r *RestAPI) validateConfig() error {
if r.BatchDelaySeconds <= 0 {
r.BatchDelaySeconds = DefaultBatchDelaySeconds
}
if r.Pagination.Scheme != PaginationSchemeItems && r.Pagination.Scheme != PaginationSchemePages {
return fmt.Errorf("invalid pagination scheme (%s), must be %s or %s",
r.Pagination.Scheme, PaginationSchemeItems, PaginationSchemePages)
}
return r.Filters.Validate()
}

Expand Down

0 comments on commit 6f4b7d2

Please sign in to comment.