func ViewWebhook(ctx *context.Context) { ctx.Data["Title"] = "View Webhook" ctx.Data["PageIsWebhook"] = true ctx.Data["RequireHighlightJS"] = true webhook, err := models.GetWebhookByID(ctx.ParamsInt64(":id")) if err != nil { if errors.IsWebhookNotFound(err) { ctx.Handle(404, "GetWebhookByID", nil) } else { ctx.Handle(500, "GetWebhookByID", err) } return } ctx.Data["Webhook"] = webhook // Prettify JSON in case it is not. buf := new(bytes.Buffer) if err = json.Indent(buf, []byte(webhook.Payload), "", " "); err != nil { ctx.Handle(500, "json.Indent", err) return } webhook.Payload = buf.String() ctx.HTML(200, "webhook/view") }
func DeleteApplication(ctx *context.Context) { if err := models.DeleteApplicationByID(ctx.ParamsInt64(":id")); err != nil { ctx.Error(500, err.Error()) return } ctx.Redirect("/applications") }
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"))) }
func DeleteCollector(ctx *context.Context) { if err := models.DeleteCollectorByID(ctx.ParamsInt64(":id")); err != nil { ctx.Error(500, err.Error()) return } ctx.Redirect("/collectors") }
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"))) }
func parseApplicationByID(ctx *context.Context) *models.Application { app, err := models.GetApplicationByID(ctx.ParamsInt64(":id")) if err != nil { if errors.IsApplicationNotFound(err) { ctx.Handle(404, "EditApplication", nil) } else { ctx.Handle(500, "GetApplicationByID", err) } return nil } ctx.Data["Application"] = app return app }
func parseCollectorByID(ctx *context.Context) *models.Collector { collector, err := models.GetCollectorByID(ctx.ParamsInt64(":id")) if err != nil { if errors.IsCollectorNotFound(err) { ctx.Handle(404, "EditApplication", nil) } else { ctx.Handle(500, "GetCollectorByID", err) } return nil } ctx.Data["Collector"] = collector return collector }