0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch-backend.git synced 2024-12-22 13:13:00 -05:00
safetwitch-backend/routes/api/clips/clips.go
2023-10-17 21:55:07 -04:00

35 lines
710 B
Go

package clips
import (
"safetwitch-backend/extractor"
"safetwitch-backend/extractor/twitch"
"github.com/gin-gonic/gin"
)
func Routes(route *gin.Engine) {
clips := route.Group("/api/clips")
clips.GET("/cliplink/:slug", func(context *gin.Context) {
slug := context.Param("slug")
data, err := twitch.GetClipLink(slug)
if err != nil {
context.Error(err)
return
}
context.JSON(200, extractor.FormatMessage(data, true))
})
clips.GET("/:slug", func(context *gin.Context) {
slug := context.Param("slug")
data, err := twitch.GetClipMetadata(slug)
if err != nil {
context.Error(err)
return
}
data.Type = "clip"
context.JSON(200, extractor.FormatMessage(data, true))
})
}