blogs api

This commit is contained in:
gom-by
2025-01-29 18:31:06 +01:00
parent 9bb72cd449
commit 107ff81e9e
7 changed files with 86 additions and 70 deletions

View File

@@ -0,0 +1,32 @@
package blogs
import (
"context"
"log"
"net/http"
"fr.latosa-escrima/api/core"
)
func HandleDelete(w http.ResponseWriter, r *http.Request) {
uuid := r.PathValue("blog_uuid")
var blog core.Blog
res, err := core.DB.NewDelete().
Model(&blog).
Where("blog_id = ?", uuid).
Returning("*").
Exec(context.Background())
if err != nil {
core.JSONError{
Status: core.Error,
Message: err.Error(),
}.Respond(w, http.StatusInternalServerError)
return
}
log.Println(res)
core.JSONSuccess{
Status: core.Success,
Message: "Blog deleted.",
}.Respond(w, http.StatusOK)
}