pkgdash/internal/handler/packages_create.go
Vasiliy Tolstov 78f0ae14d7 rewrite
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-08-16 13:17:42 +03:00

33 lines
679 B
Go

package handler
import (
"context"
"net/http"
httpsrv "go.unistack.org/micro-server-http/v4"
pb "git.unistack.org/unistack-org/pkgdash/proto"
)
func (h *Handler) PackagesCreate(ctx context.Context, req *pb.PackagesCreateReq, rsp *pb.PackagesCreateRsp) error {
logger := h.svc.Logger()
logger.Debug(ctx, "Start AddPackage")
err := req.Validate()
if err != nil {
logger.Error(ctx, err)
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return httpsrv.SetError(NewValidationError(err))
}
if h.git.IsClose() {
logger.Error(ctx, "chan is closed")
} else {
h.chanUrl <- req
}
rsp.Status = "Sent"
logger.Debug(ctx, "Success finish addPackage")
return nil
}