本文整理汇总了Golang中gitlab.com/leanlabsio/kanban/modules/middleware.Context.Broadcast方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Broadcast方法的具体用法?Golang Context.Broadcast怎么用?Golang Context.Broadcast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gitlab.com/leanlabsio/kanban/modules/middleware.Context
的用法示例。
在下文中一共展示了Context.Broadcast方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: MoveToCard
// MoveToCard updates an existing board card.
func MoveToCard(ctx *middleware.Context, form models.CardRequest) {
card, code, err := ctx.DataSource.UpdateCard(&form)
if err != nil {
ctx.JSON(code, &models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
ctx.JSON(http.StatusOK, &models.Response{
Data: card,
})
ctx.Broadcast(card.RoutingKey(), &models.Response{
Data: card,
Event: "card.move",
})
source := models.ParseLabelToStage(form.Stage["source"])
dest := models.ParseLabelToStage(form.Stage["dest"])
if source.Name != dest.Name {
com := models.CommentRequest{
CardId: form.CardId,
ProjectId: form.ProjectId,
Body: fmt.Sprintf("moved issue from **%s** to **%s**", source.Name, dest.Name),
}
go func() {
ctx.DataSource.CreateComment(&com)
}()
}
}
示例2: DeleteCard
// DeleteCard closed an existing board card.
func DeleteCard(ctx *middleware.Context, form models.CardRequest) {
card, code, err := ctx.DataSource.DeleteCard(&form)
if err != nil {
ctx.JSON(code, &models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
ctx.JSON(http.StatusOK, &models.Response{
Data: card,
})
ctx.Broadcast(card.RoutingKey(), &models.Response{
Data: card,
Event: "card.delete",
})
}
示例3: UpdateCard
// UpdateCard updates an existing board card.
func UpdateCard(ctx *middleware.Context, form models.CardRequest) {
card, code, err := models.UpdateCard(ctx.User, ctx.Provider, &form)
if err != nil {
ctx.JSON(code, &models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
ctx.JSON(http.StatusOK, &models.Response{
Data: card,
})
ctx.Broadcast(card.RoutingKey(), &models.Response{
Data: card,
Event: "card.update",
})
}