chore: 修改返回为 JSON

This commit is contained in:
Liam Chan 2024-08-22 11:55:00 +08:00
parent 91175e7509
commit 49fb4b1f91

View File

@ -12,7 +12,6 @@ import (
func CreateEventSubscription(c *gin.Context) { func CreateEventSubscription(c *gin.Context) {
xaddr := c.Param("xaddr") xaddr := c.Param("xaddr")
// FIXME: 把参数变成传入的参数
callbackURL := event.AttributedURIType(fmt.Sprintf("%s/subscriptions/callback", config.Conf.App.URL)) callbackURL := event.AttributedURIType(fmt.Sprintf("%s/subscriptions/callback", config.Conf.App.URL))
result, err := conns[xaddr].SubscribeEvents(callbackURL, "PT60S") result, err := conns[xaddr].SubscribeEvents(callbackURL, "PT60S")
if err != nil { if err != nil {
@ -33,9 +32,10 @@ func EventNotifyCallback(c *gin.Context) {
return return
} }
// TODO: handle notifications
for _, msg := range envelope.Body.Content.(*event.Notify).NotificationMessage { for _, msg := range envelope.Body.Content.(*event.Notify).NotificationMessage {
log.Println(msg.Topic.TopicKinds, msg.Message.Message) log.Println(msg.Topic.TopicKinds, msg.Message.Message)
} }
c.String(http.StatusOK, "OK") c.JSON(http.StatusOK, gin.H{"message": "OK"})
} }