relynolli-server/handlers/catalog/routes.go

21 lines
651 B
Go
Raw Normal View History

2024-03-15 21:27:45 +03:00
package catalog
import (
"relynolli-server/handlers/catalog/endpoints"
2024-03-21 23:44:50 +03:00
"relynolli-server/internal"
"time"
"github.com/gin-contrib/cache"
"github.com/gin-gonic/gin"
2024-03-15 21:27:45 +03:00
)
func HandleRoutes(parent *gin.RouterGroup) {
h := endpoints.GetHandlers()
2024-03-21 23:44:50 +03:00
cacheStore := internal.InitCacheStore()
2024-03-15 21:27:45 +03:00
catalog := parent.Group("/catalog")
2024-03-21 23:44:50 +03:00
catalog.GET("/filters", cache.CachePage(cacheStore, 15, h.GetFilters))
catalog.GET("/count", cache.CachePage(cacheStore, 15 * time.Minute, h.Count))
catalog.GET("", cache.CachePage(cacheStore, 15 * time.Minute, h.GetCatalogItems))
catalog.GET("/:code", cache.CachePage(cacheStore, 15 * time.Minute, h.GetCatalogItem))
2024-03-15 21:27:45 +03:00
}