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

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

	result, err := h.db.SelectAllFrom(data.ProductTable,
		"WHERE products.is_server")
	if err != nil {
		logger.Error(err.Error())
		return nil, ErrInternal
	}

	products := make([]data.Product, len(result))
	for i, item := range result {
		products[i] = *item.(*data.Product)
	}

	return products, nil
}
func (h *Handler) GetProducts(tkn string) ([]data.Product, error) {
	logger := h.logger.Add("method", "GetProducts")

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

	result, err := h.db.SelectAllFrom(data.ProductTable,
		"WHERE products.is_server")
	if err != nil {
		logger.Error(err.Error())
		return nil, ErrInternal
	}

	products := make([]data.Product, len(result))
	for i, item := range result {
		products[i] = *item.(*data.Product)
	}

	return products, nil
}
func ( h * Handler ) GetProducts ( tkn string ) ( [ ] data . Product , error ) { logger := h . logger . Add ( " " , " " ) if ! h . token . Check ( tkn ) { logger . Warn ( " " ) return nil , ErrAccessDenied } result , err := h . db . SelectAllFrom ( data . ProductTable , " " ) if err != nil { logger . Error ( err . Error ( ) ) return nil , ErrInternal } products := make ( [ ] data . Product , len ( result ) ) for i , item := range result { products [ i ] = * item . ( * data . Product ) } return products , nil }
// GetProducts returns all products available to the agent.
GetProducts returns all products available to the agent .