mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2024-12-23 05:32:59 -05:00
32 lines
662 B
Go
32 lines
662 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) {
|
|
data, err := twitch.GetDiscoveryPage(50, "")
|
|
if err != nil {
|
|
context.Error(err)
|
|
return
|
|
}
|
|
|
|
context.JSON(200, extractor.FormatMessage(data, true))
|
|
})
|
|
|
|
auth.GET("/:categoryName", func(context *gin.Context) {
|
|
data, err := twitch.GetDiscoveryItem(context.Param("categoryName"), 50, "")
|
|
if err != nil {
|
|
context.Error(err)
|
|
return
|
|
}
|
|
|
|
context.JSON(200, extractor.FormatMessage(data, true))
|
|
})
|
|
}
|