33 lines
679 B
Go
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
|
|
}
|