37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package catalog
|
|
|
|
import (
|
|
"os"
|
|
"relynolli-server/handlers/catalog/endpoints"
|
|
"relynolli-server/internal"
|
|
"time"
|
|
|
|
"github.com/gin-contrib/cache"
|
|
|
|
// "relynolli-server/internal"
|
|
// "time"
|
|
|
|
// "github.com/gin-contrib/cache"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func HandleRoutes(parent *gin.RouterGroup) {
|
|
h := endpoints.GetHandlers()
|
|
cacheStore := internal.InitCacheStore()
|
|
catalog := parent.Group("/catalog")
|
|
if os.Getenv("IS_PROD") == "1" {
|
|
// Caching for production usage
|
|
catalog.GET("", cache.CachePage(cacheStore, 15*time.Minute, h.GetCatalogItems))
|
|
catalog.GET("/filters", cache.CachePage(cacheStore, 15*time.Minute, h.GetFilters))
|
|
catalog.GET("/:code", cache.CachePage(cacheStore, 15*time.Minute, h.GetCatalogItem))
|
|
} else {
|
|
catalog.GET("", h.GetCatalogItems)
|
|
catalog.GET("/:code", h.GetCatalogItem)
|
|
catalog.GET("/filters", h.GetFilters)
|
|
}
|
|
|
|
// catalog.GET("/filters", cache.CachePage(cacheStore, 15, h.GetFilters))
|
|
// catalog.GET("/count", cache.CachePage(cacheStore, 15 * time.Minute, h.Count))
|
|
// catalog.GET("/:code", cache.CachePage(cacheStore, 15 * time.Minute, h.GetCatalogItem))
|
|
}
|