handle missing slug gracefully in handle-edit-snippet
This commit is contained in:
parent
9146f2640d
commit
04520a5790
1 changed files with 8 additions and 6 deletions
|
|
@ -24,11 +24,13 @@
|
|||
(defn handle-edit-snippet [{body :body-params params :query-params}]
|
||||
(let [slug (get params "slug")]
|
||||
(t/log! {:level :info, :data {:body body :slug slug}} "Received request to edit snippet")
|
||||
(if-let [slug (not-empty slug)]
|
||||
(let [{success :success :as res} (snippets.use-cases.edit/edit-snippet slug body)]
|
||||
(cond
|
||||
success {:status 200, :body "snippet updated"}
|
||||
(= (:reason res) :invalid-patch) {:status 400, :body "invalid patch"}
|
||||
:else {:status 500, :body "internal server error"}))))
|
||||
:else {:status 500, :body "internal server error"}))
|
||||
{:status 400, :body "missing slug param"})))
|
||||
|
||||
(defn handle-view-snippets [{params :query-params}]
|
||||
(if-let [limit (get params "limit")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue