Files
template-vitrine/backend/internal/modules/pricing/routes.go
T
2026-09-14 20:50:19 +02:00

25 lines
1.0 KiB
Go

package pricing
import "github.com/gin-gonic/gin"
// RegisterAdminRoutes nests price-tier management under a product, e.g.
// PUT /api/admin/products/:id/price-tiers/:tierId, so tiers are always
// managed in the context of the product they belong to.
func RegisterAdminRoutes(rg *gin.RouterGroup, h *Handler, requireAdmin gin.HandlerFunc) {
group := rg.Group("/admin/products/:id/price-tiers", requireAdmin)
group.GET("", h.ListByProduct)
group.POST("", h.Create)
group.PUT("/:tierId", h.Update)
group.DELETE("/:tierId", h.Delete)
}
// RegisterPublicRoutes exposes read-only tiers so the storefront can render
// the available quantity/price options for a product. Kept as its own
// top-level path (rather than nested under /products/:slug) because the
// products module's public detail route uses a :slug wildcard at that same
// position -- gin does not allow two different wildcard names at the same
// path segment.
func RegisterPublicRoutes(rg *gin.RouterGroup, h *Handler) {
rg.GET("/price-tiers/by-product/:id", h.ListByProduct)
}