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/clips/clips.go

36 lines
710 B
Go
Raw Permalink Normal View History

2023-08-21 22:28:23 -05:00
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")
2023-08-21 22:43:54 -05:00
clips.GET("/cliplink/:slug", func(context *gin.Context) {
2023-08-21 22:28:23 -05:00
slug := context.Param("slug")
data, err := twitch.GetClipLink(slug)
if err != nil {
context.Error(err)
return
}
context.JSON(200, extractor.FormatMessage(data, true))
})
2023-10-17 20:55:07 -05:00
clips.GET("/:slug", func(context *gin.Context) {
2023-08-21 22:28:23 -05:00
slug := context.Param("slug")
2023-10-17 20:55:07 -05:00
data, err := twitch.GetClipMetadata(slug)
2023-08-21 22:28:23 -05:00
if err != nil {
context.Error(err)
return
}
data.Type = "clip"
context.JSON(200, extractor.FormatMessage(data, true))
})
}