nidus-sync/api/query_params.go

26 lines
455 B
Go
Raw Permalink Normal View History

2026-03-10 15:46:17 +00:00
package api
type queryParams struct {
Limit *int `schema:"limit"`
Sort *string `schema:"sort"`
Type *string `schema:"type"`
}
func (qp queryParams) SortOrDefault(default_name string, ascending bool) (string, bool) {
if qp.Sort == nil {
return default_name, ascending
}
s := *qp.Sort
if s == "" {
return default_name, ascending
}
a := true
if s[0] == '-' {
a = false
}
if s[0] == '+' || s[0] == '-' {
s = s[1:]
}
return s, a
}