2023-05-26 09:17:55 -05:00
|
|
|
package discover
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
2023-05-29 21:18:04 -05:00
|
|
|
|
|
|
|
"safetwitch-backend/extractor"
|
|
|
|
"safetwitch-backend/extractor/twitch"
|
2023-05-26 09:17:55 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func Routes(route *gin.Engine) {
|
|
|
|
auth := route.Group("/api/discover")
|
|
|
|
|
2023-06-07 11:25:52 -05:00
|
|
|
auth.GET("", func(context *gin.Context) {
|
2023-05-29 21:18:04 -05:00
|
|
|
data, err := twitch.GetDiscoveryPage(50, "")
|
2023-05-26 09:17:55 -05:00
|
|
|
if err != nil {
|
|
|
|
context.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
context.JSON(200, extractor.FormatMessage(data, true))
|
|
|
|
})
|
2023-05-28 15:19:39 -05:00
|
|
|
|
|
|
|
auth.GET("/:categoryName", func(context *gin.Context) {
|
2023-05-29 21:18:04 -05:00
|
|
|
data, err := twitch.GetDiscoveryItem(context.Param("categoryName"), 50, "")
|
2023-05-28 15:19:39 -05:00
|
|
|
if err != nil {
|
|
|
|
context.Error(err)
|
|
|
|
}
|
|
|
|
|
2023-05-28 15:44:31 -05:00
|
|
|
context.JSON(200, extractor.FormatMessage(data, true))
|
2023-05-28 15:19:39 -05:00
|
|
|
})
|
2023-05-26 09:17:55 -05:00
|
|
|
}
|