Skip to content

Instantly share code, notes, and snippets.

@Develp10
Created April 15, 2022 08:52
Show Gist options
  • Select an option

  • Save Develp10/5abd93acfa81d3a0bb2cb3f46ec5b3aa to your computer and use it in GitHub Desktop.

Select an option

Save Develp10/5abd93acfa81d3a0bb2cb3f46ec5b3aa to your computer and use it in GitHub Desktop.
package products
import (
"go-fiber-api-docker/pkg/common/models"
"github.com/gofiber/fiber/v2"
)
func (h handler) GetProducts(c *fiber.Ctx) error {
var products []models.Product
if result := h.DB.Find(&products); result.Error != nil {
return fiber.NewError(fiber.StatusNotFound, result.Error.Error())
}
return c.Status(fiber.StatusOK).JSON(&products)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment