Created
April 15, 2022 09:12
-
-
Save Develp10/257b122cdf010ff6fea0e0deaccd06e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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