mirror of
https://github.com/TeamPiped/RYD-Proxy.git
synced 2024-08-14 23:55:54 +00:00
Add support for videoId query flags
This commit is contained in:
parent
c7a6438110
commit
617f8ab7ef
1 changed files with 13 additions and 2 deletions
15
main.go
15
main.go
|
@ -51,15 +51,26 @@ func main() {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
app.Get("/votes/:videoId", handler)
|
// Route for /votes?videoId=:videoId
|
||||||
|
app.Get("/votes", handleQuery)
|
||||||
|
|
||||||
|
// Route for /votes/:videoId
|
||||||
|
app.Get("/votes/:videoId", handleParam)
|
||||||
|
|
||||||
log.Fatal(app.Listen(":3000"))
|
log.Fatal(app.Listen(":3000"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func handler(c *fiber.Ctx) error {
|
func handleQuery(c *fiber.Ctx) error {
|
||||||
|
videoId := c.Query("videoId")
|
||||||
|
return getVotes(c, videoId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleParam(c *fiber.Ctx) error {
|
||||||
videoId := c.Params("videoId")
|
videoId := c.Params("videoId")
|
||||||
|
return getVotes(c, videoId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getVotes(c *fiber.Ctx, videoId string) error {
|
||||||
match, _ := regexp.Match("^([a-zA-Z0-9_-]{11})", []byte(videoId))
|
match, _ := regexp.Match("^([a-zA-Z0-9_-]{11})", []byte(videoId))
|
||||||
|
|
||||||
if !match {
|
if !match {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue