fixed bug with pageopts

This commit is contained in:
2026-02-08 17:22:29 +11:00
parent c16a82f2ad
commit 1a2bdaf4cf
2 changed files with 7 additions and 4 deletions

View File

@@ -27,10 +27,10 @@ func pageOptsFromQuery(s *hws.Server, w http.ResponseWriter, r *http.Request) *d
}
func getPageOpts(s *hws.Server, w http.ResponseWriter, r *http.Request, g validation.Getter) *db.PageOpts {
page := g.Int("page").Min(1).Value
perPage := g.Int("per_page").Min(1).Max(100).Value
order := g.String("order").TrimSpace().ToUpper().AllowedValues([]string{"ASC", "DESC"}).Value
orderBy := g.String("order_by").TrimSpace().ToLower().Value
page := g.Int("page").Optional().Min(1).Value
perPage := g.Int("per_page").Optional().Min(1).Max(100).Value
order := g.String("order").TrimSpace().ToUpper().Optional().AllowedValues([]string{"ASC", "DESC"}).Value
orderBy := g.String("order_by").TrimSpace().Optional().ToLower().Value
valid := g.ValidateAndError(s, w, r)
if !valid {
return nil