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/users/users.go
2023-07-19 20:27:36 -04:00

30 lines
612 B
Go

package users
import (
"safetwitch-backend/extractor"
"safetwitch-backend/extractor/twitch"
"github.com/gin-gonic/gin"
)
func Routes(route *gin.Engine) {
auth := route.Group("/api/users")
auth.GET("/:streamerName", func(context *gin.Context) {
data, err := twitch.GetStreamerInfo(context.Param("streamerName"))
if err != nil {
if err.Error() == "streamer not found" {
context.JSON(404, gin.H{
"status": "error",
"message": "streamer not found",
})
} else {
context.Error(err)
return
}
return
}
context.JSON(200, extractor.FormatMessage(data, true))
})
}