本文整理汇总了Golang中github.com/Unknwon/orbiter/modules/context.Context.Error方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Error方法的具体用法?Golang Context.Error怎么用?Golang Context.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Unknwon/orbiter/modules/context.Context
的用法示例。
在下文中一共展示了Context.Error方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DeleteApplication
func DeleteApplication(ctx *context.Context) {
if err := models.DeleteApplicationByID(ctx.ParamsInt64(":id")); err != nil {
ctx.Error(500, err.Error())
return
}
ctx.Redirect("/applications")
}
示例2: DeleteCollector
func DeleteCollector(ctx *context.Context) {
if err := models.DeleteCollectorByID(ctx.ParamsInt64(":id")); err != nil {
ctx.Error(500, err.Error())
return
}
ctx.Redirect("/collectors")
}
示例3: RegenerateApplicationSecret
func RegenerateApplicationSecret(ctx *context.Context) {
if err := models.RegenerateApplicationToken(ctx.ParamsInt64(":id")); err != nil {
ctx.Error(500, err.Error())
return
}
ctx.Redirect(fmt.Sprintf("/applications/%d", ctx.ParamsInt64(":id")))
}
示例4: RegenerateCollectorSecret
func RegenerateCollectorSecret(ctx *context.Context) {
if err := models.RegenerateCollectorSecret(ctx.ParamsInt64(":id")); err != nil {
ctx.Error(500, err.Error())
return
}
ctx.Redirect(fmt.Sprintf("/collectors/%d", ctx.ParamsInt64(":id")))
}
示例5: Collectors
func Collectors(ctx *context.Context) {
ctx.Data["Title"] = "Collectors"
ctx.Data["PageIsCollector"] = true
collectors, err := models.ListCollectors()
if err != nil {
ctx.Error(500, err.Error())
return
}
ctx.Data["Collectors"] = collectors
ctx.HTML(200, "collector/list")
}
示例6: Webhooks
func Webhooks(ctx *context.Context) {
ctx.Data["Title"] = "Webhooks"
ctx.Data["PageIsWebhook"] = true
webhooks, err := models.QueryWebhooks(models.QueryWebhookOptions{
Limit: 50,
Order: "created desc",
})
if err != nil {
ctx.Error(500, err.Error())
return
}
ctx.Data["Webhooks"] = webhooks
ctx.HTML(200, "webhook/list")
}
示例7: EditApplicationPost
func EditApplicationPost(ctx *context.Context, form NewApplicationForm) {
ctx.Data["Title"] = "Edit Application"
ctx.Data["PageIsApplication"] = true
app := parseApplicationByID(ctx)
if ctx.Written() {
return
}
app.Name = form.Name
if err := models.UpdateApplication(app); err != nil {
if errors.IsApplicationExists(err) {
ctx.Data["Err_Name"] = true
ctx.RenderWithErr("Application name has been used.", "application/edit", form)
} else {
ctx.Error(500, err.Error())
}
return
}
ctx.Redirect(fmt.Sprintf("/applications/%d", app.ID))
}
示例8: EditCollectorPost
func EditCollectorPost(ctx *context.Context, form NewCollectorForm) {
ctx.Data["Title"] = "Edit Collector"
ctx.Data["PageIsCollector"] = true
collector := parseCollectorByID(ctx)
if ctx.Written() {
return
}
collector.Name = form.Name
if err := models.UpdateCollector(collector); err != nil {
if errors.IsCollectorExists(err) {
ctx.Data["Err_Name"] = true
ctx.RenderWithErr("Collector name has been used.", "collector/edit", form)
} else {
ctx.Error(500, err.Error())
}
return
}
ctx.Redirect(fmt.Sprintf("/collectors/%d", collector.ID))
}
示例9: Hook
func Hook(ctx *context.Context) {
collector, err := models.GetCollectorBySecret(ctx.Query("secret"))
if err != nil {
if errors.IsCollectorNotFound(err) {
ctx.Error(403)
} else {
ctx.Error(500, err.Error())
}
return
}
payload, err := ctx.Req.Body().Bytes()
if err != nil {
ctx.Error(500, err.Error())
return
}
// NOTE: Currently only support GitHub
event, err := webhook.ParseGitHubEvent(payload)
if err != nil {
ctx.Error(500, err.Error())
return
}
if err = models.NewWebhook(&models.Webhook{
CollectorID: collector.ID,
Owner: tool.FirstNonEmptyString(event.Repository.Owner.Login, event.Repository.Owner.Name),
RepoName: event.Repository.Name,
EventType: ctx.Req.Header.Get("X-GitHub-Event"),
Sender: event.Sender.Login,
Payload: string(payload),
}); err != nil {
ctx.Error(500, err.Error())
return
}
ctx.Status(202)
}