diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-10-24 17:21:49 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-10-24 17:21:49 -0700 |
commit | e6e322b1f6c1b5d3ade5da2e1ca5cec608f72517 (patch) | |
tree | 02375854eb68042250550d8bbbe89cb5083ae600 /system/api/handlers.go | |
parent | 89e9d1ff9933c78be9719f881d98fce7de06f446 (diff) |
debugging params for post queries
Diffstat (limited to 'system/api/handlers.go')
-rw-r--r-- | system/api/handlers.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/system/api/handlers.go b/system/api/handlers.go index bbddc09..9e9fbb6 100644 --- a/system/api/handlers.go +++ b/system/api/handlers.go @@ -56,9 +56,9 @@ func postsHandler(res http.ResponseWriter, req *http.Request) { } } - order := strings.ToUpper(q.Get("order")) // string: sort order of posts by timestamp ASC / DESC (DESC default) - if order != "ASC" || order == "" { - order = "DESC" + order := strings.ToLower(q.Get("order")) // string: sort order of posts by timestamp ASC / DESC (DESC default) + if order != "asc" || order == "" { + order = "desc" } // TODO: time-based ?after=time.Time, ?before=time.Time between=time.Time|time.Time @@ -69,6 +69,8 @@ func postsHandler(res http.ResponseWriter, req *http.Request) { all = append(all, post) } + fmt.Println(len(posts)) + var start, end int switch count { case -1: @@ -89,7 +91,7 @@ func postsHandler(res http.ResponseWriter, req *http.Request) { } // reverse the sorted order if ASC - if order == "ASC" { + if order == "asc" { all = []json.RawMessage{} for i := len(posts) - 1; i >= 0; i-- { all = append(all, posts[i]) |