本文整理匯總了Golang中github.com/Unknwon/orbiter/modules/context.Context.Redirect方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Redirect方法的具體用法?Golang Context.Redirect怎麽用?Golang Context.Redirect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Unknwon/orbiter/modules/context.Context
的用法示例。
在下文中一共展示了Context.Redirect方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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")))
}
示例2: DeleteApplication
func DeleteApplication(ctx *context.Context) {
if err := models.DeleteApplicationByID(ctx.ParamsInt64(":id")); err != nil {
ctx.Error(500, err.Error())
return
}
ctx.Redirect("/applications")
}
示例3: DeleteCollector
func DeleteCollector(ctx *context.Context) {
if err := models.DeleteCollectorByID(ctx.ParamsInt64(":id")); err != nil {
ctx.Error(500, err.Error())
return
}
ctx.Redirect("/collectors")
}
示例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: NewApplicationPost
func NewApplicationPost(ctx *context.Context, form NewApplicationForm) {
ctx.Data["Title"] = "New Application"
ctx.Data["PageIsApplication"] = true
if ctx.HasError() {
ctx.HTML(200, "application/new")
return
}
app, err := models.NewApplication(form.Name)
if err != nil {
if errors.IsApplicationExists(err) {
ctx.Data["Err_Name"] = true
ctx.RenderWithErr("Application name has been used.", "application/new", form)
} else {
ctx.Handle(500, "NewApplication", err)
}
return
}
ctx.Redirect(fmt.Sprintf("/applications/%d", app.ID))
}
示例6: 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))
}
示例7: NewCollectorPost
func NewCollectorPost(ctx *context.Context, form NewCollectorForm) {
ctx.Data["Title"] = "New Collector"
ctx.Data["PageIsCollector"] = true
if ctx.HasError() {
ctx.HTML(200, "collector/new")
return
}
collector, err := models.NewCollector(form.Name, models.COLLECT_TYPE_GITHUB)
if err != nil {
if errors.IsCollectorExists(err) {
ctx.Data["Err_Name"] = true
ctx.RenderWithErr("Collector name has been used.", "collector/new", form)
} else {
ctx.Handle(500, "NewCollector", err)
}
return
}
ctx.Redirect(fmt.Sprintf("/collectors/%d", collector.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))
}