0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch-backend.git synced 2024-12-22 21:23:01 -05:00
safetwitch-backend/routes/api/discover/discover.go
2023-07-29 21:04:52 -04:00

34 lines
742 B
Go

package discover
import (
"github.com/gin-gonic/gin"
"safetwitch-backend/extractor"
"safetwitch-backend/extractor/twitch"
)
func Routes(route *gin.Engine) {
auth := route.Group("/api/discover")
auth.GET("", func(context *gin.Context) {
cursor := context.Query("cursor")
data, err := twitch.GetDiscoveryPage(50, cursor)
if err != nil {
context.Error(err)
return
}
context.JSON(200, extractor.FormatMessage(data, true))
})
auth.GET("/:categoryName", func(context *gin.Context) {
cursor := context.Query("cursor")
data, err := twitch.GetDiscoveryItem(context.Param("categoryName"), 50, cursor)
if err != nil {
context.Error(err)
return
}
context.JSON(200, extractor.FormatMessage(data, true))
})
}