Skip to content

Commit 7391013

Browse files
feat: add paging params check func as map
Co-authored-by: remoterami <142154971+remoterami@users.noreply.github.com>
1 parent 4054247 commit 7391013

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

backend/pkg/api/handlers/input_validation.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,21 @@ type Paging struct {
311311
}
312312

313313
func (v *validationError) checkPagingParams(q url.Values) Paging {
314+
return v.checkPagingMap(map[string]string{
315+
"cursor": q.Get("cursor"),
316+
"limit": q.Get("limit"),
317+
"search": q.Get("search"),
318+
})
319+
}
320+
321+
func (v *validationError) checkPagingMap(params map[string]string) Paging {
314322
paging := Paging{
315-
cursor: q.Get("cursor"),
323+
cursor: params["cursor"],
316324
limit: defaultReturnLimit,
317-
search: q.Get("search"),
325+
search: params["search"],
318326
}
319327

320-
if limitStr := q.Get("limit"); limitStr != "" {
328+
if limitStr := params["limit"]; limitStr != "" {
321329
paging.limit = v.checkUintMinMax(limitStr, 1, maxQueryLimit, "limit")
322330
}
323331

0 commit comments

Comments
 (0)