Files
Blog/app/internal/handler/deleteposthandler.go
cialloo b05f797eb1
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 52s
Implement CRUD operations for blog posts with Create, Edit, and Delete handlers
2025-10-25 11:34:59 +08:00

30 lines
728 B
Go

package handler
import (
"net/http"
"git.cialloo.com/CiallooWeb/Blog/app/internal/logic"
"git.cialloo.com/CiallooWeb/Blog/app/internal/svc"
"git.cialloo.com/CiallooWeb/Blog/app/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// Delete a blog post
func DeletePostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DeletePostReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := logic.NewDeletePostLogic(r.Context(), svcCtx)
resp, err := l.DeletePost(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}