added bulk deleteHandler.go
All checks were successful
build and deploy kleinTodo / build (push) Successful in 35s
All checks were successful
build and deploy kleinTodo / build (push) Successful in 35s
This commit is contained in:
parent
bcc43af480
commit
d63044e100
25
server/handler/deleteHandler.go
Normal file
25
server/handler/deleteHandler.go
Normal 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
|
||||
}
|
||||
}
|
||||
@ -26,6 +26,7 @@ func main() {
|
||||
mux.HandleFunc("POST /login", handler.LoginHandler)
|
||||
mux.HandleFunc("POST /store", handler.StoreHandler)
|
||||
mux.HandleFunc("GET /sync", handler.SyncHandler)
|
||||
mux.HandleFunc("DELETE /todo", handler.DeleteHandler)
|
||||
|
||||
// A simple root handler to confirm the server is running.
|
||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user