init commit

This commit is contained in:
2025-04-09 15:52:24 +08:00
parent d1c5fb1162
commit a5b87653a3
31 changed files with 718 additions and 24 deletions
+43
View File
@@ -0,0 +1,43 @@
package images
import (
"floares/lib/http/images"
"github.com/gin-gonic/gin"
"net/http"
)
func ListImages(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"data": images.List(),
"code": http.StatusOK,
})
}
func PullImage(c *gin.Context) {
type Ref struct {
Ref string `json:"ref"`
}
var ref Ref
if err := c.ShouldBind(&ref); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": http.StatusBadRequest,
"data": gin.H{
"err": err.Error(),
},
})
return
}
c.JSON(http.StatusOK, gin.H{
"data": images.Pull(ref.Ref),
"code": http.StatusOK,
})
}
func Delete(c *gin.Context) {
result := images.Delete(c.Param("id"))
c.JSON(http.StatusOK, gin.H{
"code": http.StatusOK,
"err": result.Error,
})
}
+10
View File
@@ -0,0 +1,10 @@
package images
import "github.com/gin-gonic/gin"
func RegisterRouter(c *gin.RouterGroup) {
c.GET("/", ListImages)
c.POST("/pull", PullImage)
c.DELETE("/:id", Delete)
}