Add the route and handler to delete a article.

main
KKlochko 1 year ago
parent 9177e42fb0
commit d8d8340aa2

@ -98,6 +98,20 @@
(res/status 500) (res/status 500)
(res/send (ex-message err)))))))) (res/send (ex-message err))))))))
(defn htmx-delete-article-row-handler-factory
[client]
(fn [req res]
(let [channel (chan)
id (.-id (.-params req))]
(go
(try
(let [id (<! (db/delete-article client id channel))]
(res/status 200)
(.send res ""))
(catch js/Error err
(res/status 500)
(res/send (ex-message err))))))))
(defn htmx-create-article-handler-factory (defn htmx-create-article-handler-factory
[client] [client]
(fn [req res] (fn [req res]

@ -53,6 +53,9 @@
(. app get "/htmx/admin/modals/article/content/:id/" (. app get "/htmx/admin/modals/article/content/:id/"
(handlers/htmx-get-article-preview-content-handler-factory client)) (handlers/htmx-get-article-preview-content-handler-factory client))
(. app delete "/htmx/admin/rows/article/:id/"
(handlers/htmx-delete-article-row-handler-factory client))
) )
(defn start (defn start

Loading…
Cancel
Save