pkgdash/internal/handler/package_delete.go
Vasiliy Tolstov c5f3fa325e update
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-07 02:35:30 +03:00

29 lines
770 B
Go

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
}