mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
feat: post deletion
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func GetPostDeletePage(w http.ResponseWriter, r *http.Request) {
|
||||
postId := chi.URLParam(r, "id")
|
||||
id, err := strconv.Atoi(postId)
|
||||
if err != nil {
|
||||
http.Error(w, http.StatusText(400), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
err = Container.DeletePostUseCase.DeletePost(uint32(id))
|
||||
if err != nil {
|
||||
http.Error(w, http.StatusText(400), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/post", http.StatusSeeOther)
|
||||
}
|
||||
Reference in New Issue
Block a user