pkgdash/internal/handler/package_delete.go

29 lines
770 B
Go
Raw Normal View History

package handler
import (
"context"
"net/http"
httpsrv "go.unistack.org/micro-server-http/v3"
pb "go.unistack.org/pkgdash/proto"
)
func (h *Handler) PackageDelete(ctx context.Context, req *pb.PackageDeleteReq, rsp *pb.PackageDeleteRsp) error {
h.logger.Debug(ctx, "Start UpdatePackage")
if err := req.Validate(); err != nil {
h.logger.Error(ctx, "validate error", err)
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return httpsrv.SetError(NewValidationError(err))
}
if err := h.store.PackageDelete(ctx, req); err != nil {
h.logger.Error(ctx, "package delete error", err)
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
return httpsrv.SetError(NewInternalError(err))
}
h.logger.Debug(ctx, "Success finish UpdatePackage")
return nil
}