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
}
func ( h * Handler ) CreateProduct ( tkn string , product data . Product ) ( * string , error ) { logger := h . logger . Add ( " " , " " , " " , product ) if ! h . token . Check ( tkn ) { logger . Warn ( " " ) 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.
CreateProduct creates new product .