Initial /video/[id] endpoint

This commit is contained in:
Carl Pearson
2024-09-07 06:17:21 -06:00
parent 9ca89f5509
commit 3fb3ab496f
3 changed files with 36 additions and 1 deletions

View File

@@ -255,6 +255,20 @@ func videosHandler(c echo.Context) error {
return c.Render(http.StatusOK, "videos.html", map[string]interface{}{"videos": videos})
}
func videoHandler(c echo.Context) error {
id, _ := strconv.Atoi(c.Param("id"))
var video Video
if err := db.First(&video, id).Error; err != nil {
return c.Redirect(http.StatusSeeOther, "/videos")
}
return c.Render(http.StatusOK, "video.html",
map[string]interface{}{
"video": video,
"downloadDir": getDownloadDir(),
})
}
func videoCancelHandler(c echo.Context) error {
id, _ := strconv.Atoi(c.Param("id"))
var video Video