Skip to content

Commit

Permalink
Merge pull request #9 from glosa/develop
Browse files Browse the repository at this point in the history
Fix Delete request
  • Loading branch information
tanrax authored Feb 22, 2021
2 parents 2822a32 + e926379 commit 5f4b91e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ Delete a comment for ID. [Authorization required](#authorization).
**Method**: `DELETE`

``` sh
/api/v1/comments/
/api/v1/comments/{id}
```

| Param | Value | Description |
Expand All @@ -544,9 +544,7 @@ Delete a comment for ID. [Authorization required](#authorization).
Delete comment with id `1234`.

``` sh
curl -XDELETE -H "Authorization: Bearer mysecret" -H "Content-type: application/json" -d '{
"id": 1234
}' 'http://localhost:4000/api/v1/comments/
curl -XDELETE -H "Authorization: Bearer mysecret" -H "Content-type: application/json" http://localhost:4000/api/v1/comments/1234
```

##### Success response
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject glosa "1.3.6"
(defproject glosa "1.3.8"
:description "glosa"
:url "https://github.com/tanrax/glosa"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/glosa/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(wrap-defaults (assoc-in site-defaults [:security :anti-forgery] false))
(wrap-cors
:access-control-allow-origin [(re-pattern (if (config :debug) ".*" (config :domain-cli)))]
:access-control-allow-methods [:get :post])
:access-control-allow-methods [:get :post :put :delete])
(#(if (config :debug) (wrap-reload %) %))))

(defn -main [& args]
Expand Down
2 changes: 1 addition & 1 deletion src/glosa/urls.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(POST "/comments/latest/:pag" [] view-private/get-latest-comments)
(POST "/threads/search/:query" [] view-private/get-search-threads)
(PUT "/comments/" [] view-private/update-comment)
(DELETE "/comments/" [] view-private/delete-comment)))
(DELETE "/comments/:id" [] view-private/delete-comment)))

(defroutes resources-routes
;; Resources (statics)
Expand Down
12 changes: 6 additions & 6 deletions src/glosa/views/private.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
(response-401 req))))

(defn delete-comment
"Delete one comment"
[req]
(let [id (:id (get-JSON req))]
(if (check-bearer-token req)
(render-JSON req {:deleted (database/delete-comment id) :id (bigint id)})
(response-401 req))))
"Delete one comment"
[req]
(let [id (-> req :params :id)]
(if (check-bearer-token req)
(render-JSON req {:deleted (database/delete-comment id) :id (bigint id)})
(response-401 req))))

0 comments on commit 5f4b91e

Please sign in to comment.