added bulk deleteHandler.go
All checks were successful
build and deploy kleinTodo / build (push) Successful in 35s

This commit is contained in:
Darius klein 2026-01-18 13:54:28 +01:00
parent bcc43af480
commit d63044e100
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package handler
import (
"net/http"
"gitea.kleinsense.nl/DariusKlein/kleinTodo/common"
"gitea.kleinsense.nl/DariusKlein/kleinTodo/common/jwt"
)
func DeleteHandler(w http.ResponseWriter, r *http.Request) {
user, err := jwt.GetVerifiedUser(r)
if handleError(w, http.StatusUnauthorized, err) {
return
}
store, err := common.GetTodoDataStore()
if handleError(w, http.StatusInternalServerError, err) {
return
}
err = store.EmptyBucket(user)
if handleError(w, http.StatusInternalServerError, err) {
return
}
}

View File

@ -26,6 +26,7 @@ func main() {
mux.HandleFunc("POST /login", handler.LoginHandler) mux.HandleFunc("POST /login", handler.LoginHandler)
mux.HandleFunc("POST /store", handler.StoreHandler) mux.HandleFunc("POST /store", handler.StoreHandler)
mux.HandleFunc("GET /sync", handler.SyncHandler) mux.HandleFunc("GET /sync", handler.SyncHandler)
mux.HandleFunc("DELETE /todo", handler.DeleteHandler)
// A simple root handler to confirm the server is running. // A simple root handler to confirm the server is running.
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {