Skip to content

Commit

Permalink
Use GET for the delete path for convenience, just like
Browse files Browse the repository at this point in the history
the OG repo has done. This is obviously bad. We can use HTMX to fix it
cleanly, instead of doing the usual workarounds.
  • Loading branch information
adityaathalye committed Sep 3, 2024
1 parent 446bd03 commit 200b378
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/usermanager/layouts/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
[:tr (for [field [id name email department action]]
[:td field])]))
users)
[:tr [:td {:colspan (count table-headers)}]
"No users exist but "
[:a {:href "/user/form"} "new ones can be added"]"."])]]))
(list [:tr [:td {:colspan (count table-headers)}
"No users exist but "
[:a {:href "/user/form"} "new ones can be added"] "."]]))]]))

(def uri->page-name
{"/" "Home"
Expand Down
2 changes: 1 addition & 1 deletion src/usermanager/router/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
[_]
handlers/default)

(defmethod router [:delete "/user/delete/:id"]
(defmethod router [:get "/user/delete/:id"]
[_]
(middleware/wrap-route-id-params
handlers/delete-by-id
Expand Down
2 changes: 1 addition & 1 deletion test/usermanager/handlers/user_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@
(is (= {:status 200
:trace-redirects [(str base-uri "user/list")]
:body ""}
(-> (http/delete (str base-uri "user/delete/42"))
(-> (http/get (str base-uri "user/delete/42"))
(select-keys [:status :body :trace-redirects])))))))
4 changes: 2 additions & 2 deletions test/usermanager/router/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
:application/view "list"}

;; 3. DELETE
(handle {:request-method :delete
(handle {:request-method :get
:uri "/user/delete/2"
:application/component {:database db}})
{:status 303
Expand Down Expand Up @@ -190,7 +190,7 @@
:application/view "list"}

;; Delete the lone user
(handle {:request-method :delete
(handle {:request-method :get
:uri "/user/delete/1"
:params {:id 1} ; We assume setup creates at least one user
:application/component {:database db}})
Expand Down

0 comments on commit 200b378

Please sign in to comment.