small cleanup
This commit is contained in:
parent
ee9708be55
commit
7b1b0f1cc5
13
main.go
13
main.go
@ -68,8 +68,6 @@ func main() {
|
||||
}
|
||||
|
||||
func initUpload(c *gin.Context) {
|
||||
var err error
|
||||
|
||||
fileName, err := io.ReadAll(c.Request.Body)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, "Couldn't read html request body")
|
||||
@ -141,19 +139,18 @@ func finishUpload(c *gin.Context) {
|
||||
func listVideos(c *gin.Context) {
|
||||
allVideos := map[int]string{}
|
||||
|
||||
var err error
|
||||
rows, _ := dbpool.Query(context.Background(), "select * from videos")
|
||||
for rows.Next() {
|
||||
var id int
|
||||
var filepath string
|
||||
err = rows.Scan(&id, &filepath)
|
||||
err := rows.Scan(&id, &filepath)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, "")
|
||||
log.Panicf("listVideos: %v\n", err)
|
||||
}
|
||||
allVideos[id] = filepath
|
||||
}
|
||||
err = rows.Err()
|
||||
err := rows.Err()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, "")
|
||||
log.Panicf("listVideos: %v\n", err)
|
||||
@ -163,10 +160,9 @@ func listVideos(c *gin.Context) {
|
||||
}
|
||||
|
||||
func getVideo(c *gin.Context) {
|
||||
var err error
|
||||
rows, _ := dbpool.Query(context.Background(), "select filepath from videos where id = $1", c.Param("id"))
|
||||
rows.Next()
|
||||
err = rows.Err()
|
||||
err := rows.Err()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, "")
|
||||
log.Panicf("getVideo: %v\n", err)
|
||||
@ -183,10 +179,9 @@ func getVideo(c *gin.Context) {
|
||||
}
|
||||
|
||||
func deleteVideo(c *gin.Context) {
|
||||
var err error
|
||||
rows, _ := dbpool.Query(context.Background(), "select filepath from videos where id = $1", c.Param("id"))
|
||||
rows.Next()
|
||||
err = rows.Err()
|
||||
err := rows.Err()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, "")
|
||||
log.Panicf("deleteVideo: %v\n", err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user