Skip to content

Instantly share code, notes, and snippets.

@Develp10
Created April 15, 2022 09:12
Show Gist options
  • Save Develp10/257b122cdf010ff6fea0e0deaccd06e1 to your computer and use it in GitHub Desktop.
Save Develp10/257b122cdf010ff6fea0e0deaccd06e1 to your computer and use it in GitHub Desktop.
package products
import (
"github.com/gofiber/fiber/v2"
"gorm.io/gorm"
)
type handler struct {
DB *gorm.DB
}
func RegisterRoutes(app *fiber.App, db *gorm.DB) {
h := &handler{
DB: db,
}
routes := app.Group("/products")
routes.Post("/", h.AddProduct)
routes.Get("/", h.GetProducts)
routes.Get("/:id", h.GetProduct)
routes.Put("/:id", h.UpdateProduct)
routes.Delete("/:id", h.DeleteProduct)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment