diff --git a/bruno/CodeSnippets/get_snippets.bru b/bruno/CodeSnippets/get_snippets.bru index 4b186b6..a04a48a 100644 --- a/bruno/CodeSnippets/get_snippets.bru +++ b/bruno/CodeSnippets/get_snippets.bru @@ -5,16 +5,20 @@ meta { } get { - url: {{host}}/api/snippets?limit=2&skip=0 + url: {{host}}/api/snippets?limit=100&skip=0 body: none auth: none } params:query { - limit: 2 + limit: 100 skip: 0 } +headers { + ~Accept: application/edn +} + body:json { { "title": "Test Snippet", diff --git a/src/snippets/use_cases/view.clj b/src/snippets/use_cases/view.clj index 2c58764..2357c32 100644 --- a/src/snippets/use_cases/view.clj +++ b/src/snippets/use_cases/view.clj @@ -10,13 +10,15 @@ (assoc snippet :pub-date (.toString (:pub-date snippet))))) (defn view-snippets [options] - (if (nil? options) - (map serialize-snippet (db/list-snippets)) - (let [limit (:limit options) - skip (:skip options)] - (->> (db/list-snippets) - (sort-by :pub-date) - (reverse) + (let [limit (:limit options) + skip (:skip options) + snippets (->> (db/list-snippets) + (sort-by :pub-date) + (reverse))] + + (if (nil? options) + (map serialize-snippet snippets) + (->> snippets (drop skip) (take limit) (map serialize-snippet)))))