27 lines
646 B
Go
27 lines
646 B
Go
package article
|
|
|
|
import (
|
|
"os"
|
|
"relynolli-server/handlers/article/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("/articles")
|
|
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))
|
|
} else {
|
|
catalog.GET("", h.GetNews)
|
|
catalog.GET("/:code", h.RetrieveNews)
|
|
}
|
|
|
|
}
|