[agent-operator] - 增加镜像同步的消息通知内容
This commit is contained in:
38
message_pusher/router/ImageSyncRouter.go
Normal file
38
message_pusher/router/ImageSyncRouter.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"io.wdd.message_pusher/cmii"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func ImageSyncRouter(r *gin.Engine) {
|
||||
octopusGroup := r.Group("/image")
|
||||
{
|
||||
octopusGroup.POST("/sync", ImageSync)
|
||||
}
|
||||
}
|
||||
|
||||
// ImageSync godoc
|
||||
// @Summary 镜像同步消息
|
||||
// @Schemes
|
||||
// @Description response to cmii update notification
|
||||
// @Tags ImageSync
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body cmii.ImageSyncMessage true "请求体"
|
||||
// @Success 200 {object} pusher.Message
|
||||
// @Router /image/sync [post]
|
||||
func ImageSync(c *gin.Context) {
|
||||
// 获取请求中的参数
|
||||
var imageSyncMessage cmii.ImageSyncMessage
|
||||
if err := c.ShouldBindJSON(&imageSyncMessage); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request body"})
|
||||
return
|
||||
}
|
||||
// 处理请求
|
||||
upgradeMessage := imageSyncMessage.PublishMessage()
|
||||
|
||||
// *pusher.Message
|
||||
c.JSON(http.StatusOK, upgradeMessage)
|
||||
}
|
||||
Reference in New Issue
Block a user