relynolli-server/handlers/news/routes.go

28 lines
637 B
Go
Raw Permalink Normal View History

2024-03-26 02:21:35 +03:00
package news
import (
"os"
"relynolli-server/handlers/news/endpoints"
"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("/news")
if os.Getenv("IS_PROD") == "1" {
// Caching for production usage
catalog.GET("", cache.CachePage(cacheStore, 15*time.Minute, h.GetNews))
catalog.GET("/:code", cache.CachePage(cacheStore, 15*time.Minute, h.RetrieveNews))
2024-05-03 11:57:53 +03:00
} else {
2024-03-26 02:21:35 +03:00
2024-05-03 11:57:53 +03:00
catalog.GET("", h.GetNews)
catalog.GET("/:code", h.RetrieveNews)
}
2024-03-26 02:21:35 +03:00
}