mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2024-12-22 13:13:00 -05:00
33 lines
645 B
Go
33 lines
645 B
Go
package badges
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"safetwitch-backend/extractor"
|
|
"safetwitch-backend/extractor/twitch"
|
|
)
|
|
|
|
func Routes(route *gin.Engine) {
|
|
auth := route.Group("/api/badges")
|
|
|
|
auth.GET("", func(context *gin.Context) {
|
|
query := context.Query("streamerName")
|
|
if query != "" {
|
|
data, err := twitch.GetStreamerBadges(query)
|
|
if err != nil {
|
|
context.Error(err)
|
|
return
|
|
}
|
|
|
|
context.JSON(200, extractor.FormatMessage(data, true))
|
|
} else {
|
|
data, err := twitch.GetTwitchBadges()
|
|
if err != nil {
|
|
context.Error(err)
|
|
return
|
|
}
|
|
|
|
context.JSON(200, extractor.FormatMessage(data, true))
|
|
}
|
|
})
|
|
}
|