diff options
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]) |