From fab8de7187571a4f3f8a30966057d661a858b645 Mon Sep 17 00:00:00 2001 From: knotteye Date: Fri, 2 Jul 2021 15:10:49 -0500 Subject: add deletion of news items --- main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 3eb47c0..f98add9 100644 --- a/main.go +++ b/main.go @@ -634,6 +634,21 @@ func main() { http.Redirect(w, r, "/", http.StatusSeeOther) }) + + http.HandleFunc("/" + *Key + "/newsdelete/", func(w http.ResponseWriter, r *http.Request){ + timestamp := r.URL.Path[13+len(*Key):] + + tsint, err := strconv.Atoi(timestamp) + + if(err != nil){ + w.WriteHeader(http.StatusForbidden) + w.Write([]byte("404 no path")) + return + } else { + deleteNewsItemFromDB(db, tsint) + http.Redirect(w, r, "/news/", http.StatusSeeOther) + } + }) http.HandleFunc("/verify", func(w http.ResponseWriter, r *http.Request){ if(r.Method == "POST") { -- cgit v1.2.3