chore: fix some validation issues

This commit is contained in:
2026-04-29 15:23:13 +02:00
parent 6669fda371
commit da3dee9ae7
5 changed files with 47 additions and 27 deletions
+5 -21
View File
@@ -1,7 +1,6 @@
package assets
import (
"fmt"
"net/http"
"time"
@@ -50,27 +49,12 @@ func FileDownloadResponse(c *gin.Context, fp string) {
c.File(fp)
}
func BasicResponse(c *gin.Context, data ...any) {
fmt.Println(len(data))
switch len(data) {
case 0:
// empty slice so just an ok message
c.JSON(http.StatusOK, ResponseObject{
Msg: OkMes,
})
func BasicResponse(c *gin.Context, data any) {
// single object in our slice (even if the object itself is a slice)
case 1:
c.JSON(http.StatusOK, ResponseObject{
Msg: OkMes,
Data: data[0],
})
// multiple objects inside our slice
default:
c.JSON(http.StatusOK, ResponseObject{
Msg: OkMes,
Data: data,
})
}
c.JSON(http.StatusOK, ResponseObject{
Msg: OkMes,
Data: data,
})
}
func CreationResponse(c *gin.Context, data any) {