File tree Expand file tree Collapse file tree 3 files changed +21
-25
lines changed Expand file tree Collapse file tree 3 files changed +21
-25
lines changed Original file line number Diff line number Diff line change @@ -23,13 +23,13 @@ import (
2323)
2424
2525type FilterParams struct {
26- ObjectType []string
27- ObjectId []string
28- Relation []string
29- SubjectType []string
30- SubjectId []string
31- SubjectRelation []string
32- Policy Policy
26+ ObjectType []string `json:"objectType,omitempty"`
27+ ObjectId []string `json:"objectId,omitempty"`
28+ Relation []string `json:"relation,omitempty"`
29+ SubjectType []string `json:"subjectType,omitempty"`
30+ SubjectId []string `json:"subjectId,omitempty"`
31+ SubjectRelation []string `json:"subjectRelation,omitempty"`
32+ Policy Policy `json:"policy,omitempty"`
3333}
3434
3535func (fp FilterParams ) String () string {
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ import (
2222)
2323
2424type FilterOptions struct {
25- ObjectType string
25+ ObjectType string `json:"objectType,omitempty"`
2626}
2727
2828type ObjectSpec struct {
Original file line number Diff line number Diff line change @@ -42,19 +42,15 @@ const (
4242 defaultPage = 1
4343 contextKeyListParams key = iota
4444
45- SortOrderAsc SortOrder = iota
46- SortOrderDesc SortOrder = iota
45+ SortOrderAsc SortOrder = "ASC"
46+ SortOrderDesc SortOrder = "DESC"
4747)
4848
49- type SortOrder int
49+ type SortOrder string
5050
5151func (so SortOrder ) String () string {
52- if so == SortOrderAsc {
53- return "ASC"
54- }
55-
56- if so == SortOrderDesc {
57- return "DESC"
52+ if so == SortOrderAsc || so == SortOrderDesc {
53+ return string (so )
5854 }
5955
6056 return ""
@@ -155,18 +151,18 @@ type ListParamParser interface {
155151}
156152
157153type ListParams struct {
158- Page int
159- Limit int
160- Query * string
161- SortBy string
162- SortOrder SortOrder
163- NextCursor * Cursor
164- PrevCursor * Cursor
154+ Page int `json:"-"`
155+ Limit int `json:"limit,omitempty"`
156+ Query * string `json:"q,omitempty"`
157+ SortBy string `json:"sortBy,omitempty"`
158+ SortOrder SortOrder `json:"sortOrder,omitempty"`
159+ PrevCursor * Cursor `json:"prevCursor,omitempty"`
160+ NextCursor * Cursor `json:"nextCursor,omitempty"`
165161 defaultSortBy string
166162}
167163
168164func (lp ListParams ) String () string {
169- s := fmt .Sprintf ("page=%d&limit=%d&sortBy=%s&sortOrder=%d &defaultSortBy=%s" ,
165+ s := fmt .Sprintf ("page=%d&limit=%d&sortBy=%s&sortOrder=%s &defaultSortBy=%s" ,
170166 lp .Page ,
171167 lp .Limit ,
172168 lp .SortBy ,
You can’t perform that action at this time.
0 commit comments