diff --git a/router/handler/onvif/notification.go b/router/handler/onvif/notification.go index 126a330..e7b067f 100644 --- a/router/handler/onvif/notification.go +++ b/router/handler/onvif/notification.go @@ -9,3 +9,15 @@ import ( func GetNotifications(c *gin.Context) { response.NewResponse().WithData(onvif.Notifications).Send(c) } + +func GetNotificationByXaddr(c *gin.Context) { + xaddr := c.Param("xaddr") + response.NewResponse().WithData(onvif.Notifications[xaddr]).Send(c) +} + +func DeleteNotificationByXaddr(c *gin.Context) { + xaddr := c.Param("xaddr") + delete(onvif.Notifications, xaddr) + + response.NewResponse().Success().Send(c) +} diff --git a/router/handler/onvif/session.go b/router/handler/onvif/session.go index ee1b095..273a5ff 100644 --- a/router/handler/onvif/session.go +++ b/router/handler/onvif/session.go @@ -71,7 +71,7 @@ func GetSessionByXaddr(c *gin.Context) { response.NewResponse().WithData(info).Send(c) } -func DeleteSession(c *gin.Context) { +func DeleteSessionByXaddr(c *gin.Context) { xaddr := c.Param("xaddr") delete(onvif.Sessions, xaddr) diff --git a/router/router.go b/router/router.go index 9270536..0e047d3 100644 --- a/router/router.go +++ b/router/router.go @@ -17,7 +17,7 @@ func SetupRoutes(r *gin.Engine) { connectionGroup.POST("/", onvif.CreateSession) connectionGroup.GET("/", onvif.GetSessions) connectionGroup.GET("/:xaddr", onvif.GetSessionByXaddr) - connectionGroup.DELETE("/:xaddr", onvif.DeleteSession) + connectionGroup.DELETE("/:xaddr", onvif.DeleteSessionByXaddr) } subscriptionGroup := onvifGroup.Group("/subscriptions") @@ -29,6 +29,8 @@ func SetupRoutes(r *gin.Engine) { notificationGroup := onvifGroup.Group("/notifications") { notificationGroup.GET("/", onvif.GetNotifications) + notificationGroup.GET("/:xaddr", onvif.GetNotificationByXaddr) + notificationGroup.DELETE("/:xaddr", onvif.DeleteNotificationByXaddr) } }