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:
Dmitry Harnitski
2017-04-19 23:22:28 -04:00
committed by GitHub
parent 4faa8d4728
commit 4446f727ea

View File

@@ -141,7 +141,7 @@ When the match is made on the `HandleFunc` function, the URL is matched, so supp
http.HandleFunc("/delete/", views.DeleteTaskFunc)
//DeleteTaskFunc is used to delete a task, trash = move to recycle bin, delete = permanent delete
func DeleteTaskFunc(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
if r.Method == "DELETE" {
id := r.URL.Path[len("/delete/"):]
if id == "all" {
db.DeleteAll()