All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 52s
30 lines
728 B
Go
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)
|
|
}
|
|
}
|
|
}
|