03.4.md - use DELETE HTTP method
In REST we should use DELETE HTTP method for deletion - http://www.restapitutorial.com/lessons/httpmethods.html
This commit is contained in:
@@ -141,7 +141,7 @@ When the match is made on the `HandleFunc` function, the URL is matched, so supp
|
|||||||
http.HandleFunc("/delete/", views.DeleteTaskFunc)
|
http.HandleFunc("/delete/", views.DeleteTaskFunc)
|
||||||
//DeleteTaskFunc is used to delete a task, trash = move to recycle bin, delete = permanent delete
|
//DeleteTaskFunc is used to delete a task, trash = move to recycle bin, delete = permanent delete
|
||||||
func DeleteTaskFunc(w http.ResponseWriter, r *http.Request) {
|
func DeleteTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == "GET" {
|
if r.Method == "DELETE" {
|
||||||
id := r.URL.Path[len("/delete/"):]
|
id := r.URL.Path[len("/delete/"):]
|
||||||
if id == "all" {
|
if id == "all" {
|
||||||
db.DeleteAll()
|
db.DeleteAll()
|
||||||
|
|||||||
Reference in New Issue
Block a user