ui/product.go
func (h *Handler) CreateProduct(tkn string,
	product data.Product) (*string, error) {
	logger := h.logger.Add("method", "CreateProduct", "product", product)

	if !h.token.Check(tkn) {
		logger.Warn("access denied")
		return nil, ErrAccessDenied
	}

	if product.ServiceEndpointAddress != nil &&
		!isValidSEAddress(*product.ServiceEndpointAddress) {
		return nil, ErrBadServiceEndpointAddress
	}

	product.ID = util.NewUUID()
	if err := insert(logger, h.db.Querier, &product); err != nil {
		return nil, err
	}

	return &product.ID, nil
}
func (h *Handler) CreateProduct(tkn string,
	product data.Product) (*string, error) {
	logger := h.logger.Add("method", "CreateProduct", "product", product)

	if !h.token.Check(tkn) {
		logger.Warn("access denied")
		return nil, ErrAccessDenied
	}

	if product.ServiceEndpointAddress != nil &&
		!isValidSEAddress(*product.ServiceEndpointAddress) {
		return nil, ErrBadServiceEndpointAddress
	}

	product.ID = util.NewUUID()
	if err := insert(logger, h.db.Querier, &product); err != nil {
		return nil, err
	}

	return &product.ID, nil
}
// CreateProduct creates new product.