feat: 改造 zbx 路由为 RPC 风格,添加了通知消费者接口
This commit is contained in:
parent
c8b33a27f6
commit
254b41e160
@ -8,7 +8,7 @@ import (
|
||||
service "onvif-agent/service/onvif"
|
||||
)
|
||||
|
||||
func ONVIFDeviceDiscovery(c *gin.Context) {
|
||||
func DiscoverONVIFDevices(c *gin.Context) {
|
||||
type ZBXDevice struct {
|
||||
Xaddr string `json:"{#XADDR}"`
|
||||
}
|
||||
@ -25,7 +25,7 @@ func ONVIFDeviceDiscovery(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
func ONVIFDeviceRegister(c *gin.Context) {
|
||||
func RegisterONVIFDevices(c *gin.Context) {
|
||||
var req []handler.CreateSessionRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
response.NewResponse().Error(err).Send(c)
|
||||
@ -55,3 +55,20 @@ func ONVIFDeviceRegister(c *gin.Context) {
|
||||
|
||||
response.NewResponse().Success().Send(c)
|
||||
}
|
||||
|
||||
type ConsumeNotificationsRequest struct {
|
||||
Xaddr string `json:"xaddr"`
|
||||
}
|
||||
|
||||
func ConsumeONVIFNotifications(c *gin.Context) {
|
||||
var req ConsumeNotificationsRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
response.NewResponse().Error(err).Send(c)
|
||||
return
|
||||
}
|
||||
|
||||
n := service.Notifications[req.Xaddr]
|
||||
delete(service.Notifications, req.Xaddr)
|
||||
|
||||
response.NewResponse().WithData(n).Send(c)
|
||||
}
|
||||
|
@ -36,7 +36,8 @@ func SetupRoutes(r *gin.Engine) {
|
||||
|
||||
zabbixGroup := r.Group("/zabbix")
|
||||
{
|
||||
zabbixGroup.POST("/onvifDeviceDiscovery", zabbixagent.ONVIFDeviceDiscovery)
|
||||
zabbixGroup.POST("/onvifDeviceRegister", zabbixagent.ONVIFDeviceRegister)
|
||||
zabbixGroup.POST("/DiscoverONVIFDevices", zabbixagent.DiscoverONVIFDevices)
|
||||
zabbixGroup.POST("/RegisterONVIFDevices", zabbixagent.RegisterONVIFDevices)
|
||||
zabbixGroup.POST("/ConsumeONVIFNotifications", zabbixagent.ConsumeONVIFNotifications)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user