package handler import ( "net/http" "strconv" "git.unistack.org/unistack-org/pkgdash/internal/storage" pb "git.unistack.org/unistack-org/pkgdash/proto" "github.com/google/uuid" jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v4" "go.unistack.org/micro/v4/codec" ) type Handler struct { store storage.Storage codec codec.Codec chanUrl chan *pb.PackagesCreateReq } func NewNotFoundError(err error) *pb.ErrorRsp { return &pb.ErrorRsp{ Code: strconv.Itoa(http.StatusBadRequest), Title: "NotFound", Uuid: uuid.New().String(), Details: err.Error(), } } func NewInternalError(err error) *pb.ErrorRsp { return &pb.ErrorRsp{ Code: strconv.Itoa(http.StatusInternalServerError), Title: "InternalServerError", Uuid: uuid.New().String(), Details: err.Error(), } } func NewValidationError(err error) *pb.ErrorRsp { return &pb.ErrorRsp{ Code: strconv.Itoa(http.StatusBadRequest), Title: "BadRequest", Uuid: uuid.New().String(), Details: err.Error(), } } func NewHandler(store storage.Storage) (*Handler, error) { h := &Handler{ codec: jsonpbcodec.NewCodec(), store: store, } return h, nil }