add delete endpoint for blog articles

Signed-off-by: Tobias Erbshäußer <tobias@tesoft.dev>
This commit is contained in:
2026-05-24 09:23:02 +02:00
parent f327509f5e
commit bf391ed7d5
3 changed files with 61 additions and 0 deletions
+21
View File
@@ -259,6 +259,27 @@ func (h *ApiHandler) ServeBlogGetSingle(writer http.ResponseWriter, request *htt
WriteResponse(writer, http.StatusOK, article)
}
func (h *ApiHandler) ServeBlogDelete(writer http.ResponseWriter, request *http.Request) {
idStr := request.PathValue("id")
id, err := strconv.ParseInt(idStr, 10, 64)
if err != nil {
WriteError(writer, http.StatusBadRequest, "invalid id", err)
return
}
err = h.db.DeleteBlogArticle(id)
if err != nil {
if errors.Is(err, ErrNotFound) {
WriteError(writer, http.StatusNotFound, "article not found", nil)
} else {
WriteError(writer, http.StatusInternalServerError, "failed to update database", err)
}
return
}
WriteResponse(writer, http.StatusOK, map[string]interface{}{})
}
func (h *ApiHandler) ServeBlogFileGetSingle(writer http.ResponseWriter, request *http.Request) {
idStr := request.PathValue("articleId")
articleId, err := strconv.ParseInt(idStr, 10, 64)