本文整理匯總了Golang中github.com/codegangsta/martini-contrib/render.Render.Redirect方法的典型用法代碼示例。如果您正苦於以下問題:Golang Render.Redirect方法的具體用法?Golang Render.Redirect怎麽用?Golang Render.Redirect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/codegangsta/martini-contrib/render.Render
的用法示例。
在下文中一共展示了Render.Redirect方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: validateSession
func validateSession(r render.Render, s sessions.Session) {
isLogin := s.Get("IsLogin")
if isLogin == nil {
fmt.Println("Not login...")
r.Redirect("/admin/login")
}
}
示例2: AdminAddTips
func AdminAddTips(req *http.Request, r render.Render, db *mgo.Database) {
content := req.FormValue("tip")
comment := req.FormValue("comment")
tip := models.Tips{Id: bson.NewObjectId(), Content: content, Comment: comment}
db.C("tips").Insert(tip)
r.Redirect("/admin/tips")
}
示例3: ShowLoginPage
func ShowLoginPage(r render.Render, s sessions.Session) {
isLogin := s.Get("IsLogin")
if isLogin != nil {
r.Redirect("/admin/index")
return
}
r.HTML(200, "admin/login", map[string]interface{}{
"IsAbout": true}, render.HTMLOptions{})
}
示例4: AdminAddCasts
func AdminAddCasts(req *http.Request, r render.Render, db *mgo.Database) {
author := req.FormValue("author")
aurhor_url := req.FormValue("authorurl")
title := req.FormValue("title")
intro := req.FormValue("intro")
show_notes := req.FormValue("shownotes")
url := req.FormValue("url")
logo_url := req.FormValue("logourl")
cast := models.Casts{Id: bson.NewObjectId(), Author: author, AuthorUrl: aurhor_url,
VisitCount: 0, Title: title, Intro: intro, ShowNotes: show_notes, Url: url, LogoUrl: logo_url}
db.C("casts").Insert(cast)
r.Redirect("/admin/casts")
}
示例5: issueRedirectHandler
func issueRedirectHandler(render render.Render, r *http.Request, params martini.Params) {
organization := params["org"]
repo := params["repo"]
issueID := params["issue_id"]
url := fmt.Sprintf("https://github.com/%s/%s/issues/%s", organization, repo, issueID)
render.Redirect(url)
}
示例6: prRedirectHandler
func prRedirectHandler(render render.Render, r *http.Request, params martini.Params) {
organization := params["org"]
repo := params["repo"]
pullRequestID := params["pull_id"]
url := fmt.Sprintf("https://github.com/%s/%s/pull/%s", organization, repo, pullRequestID)
render.Redirect(url)
}
示例7: AdminUpdateCasts
func AdminUpdateCasts(r render.Render, db *mgo.Database, req *http.Request) {
author := req.FormValue("author")
author_url := req.FormValue("authorurl")
title := req.FormValue("title")
intro := req.FormValue("intro")
show_notes := req.FormValue("shownotes")
url := req.FormValue("url")
logo_url := req.FormValue("logourl")
db.C("casts").UpdateId(bson.ObjectIdHex(req.FormValue("id")),
bson.M{"$set": bson.M{"author": author,
"authorurl": author_url,
"title": title,
"intro": intro,
"shownotes": show_notes,
"url": url,
"logourl": logo_url}})
r.Redirect("/admin/casts")
}
示例8: HandleLogin
func HandleLogin(req *http.Request, r render.Render, s sessions.Session, db *mgo.Database) {
username := req.FormValue("username")
pass := req.FormValue("password")
id := models.Identity{}
err := db.C("id").Find(bson.M{"email": "[email protected]"}).One(&id)
if err != nil {
fmt.Println(err.Error())
}
if username == "[email protected]" && bcrypt.CompareHashAndPassword(id.Password, []byte(pass)) == nil {
fmt.Println("Login success!")
s.Set("IsLogin", true)
r.Redirect("/admin/index")
} else {
r.Redirect("/admin/login")
}
}
示例9: Authorize
// Check user authentication
func Authorize(r render.Render, sess sessions.Session) {
email := sess.Get("email")
if email != nil {
user, err := common.FindCachedUser(email.(string))
if err == common.ErrSendingElasticSearchRequest {
r.Redirect("/maintenance")
return
}
if user == nil {
r.Redirect("/login")
return
}
} else {
r.Redirect("/login")
}
}
示例10: New
// New - Method for convertation POST DOT plaintext into base64
// and Redirect for rendering
func (dotviz *DotVizController) New(r render.Render, req *http.Request, res http.ResponseWriter) {
dotString := req.FormValue("text")
dotBase64 := base64.StdEncoding.EncodeToString([]byte(dotString))
r.Redirect(fmt.Sprintf("/dotviz/%v", dotBase64))
}
示例11: RedirectIfAuthorized
// Redirect user to Dashboard if authorized
func RedirectIfAuthorized(r render.Render, sess sessions.Session) {
email := sess.Get("email")
if email != nil {
r.Redirect("/")
}
}
示例12: AdminDelTips
func AdminDelTips(req *http.Request, r render.Render, db *mgo.Database) {
id := req.FormValue("Id")
db.C("tips").RemoveId(bson.ObjectIdHex(id))
r.Redirect("/admin/tips")
}
示例13: LoginRequired
// LoginRequired verifies that the current user is authenticated. Any routes that
// require a login should have this handler placed in the flow. If the user is not
// authenticated, they will be redirected to /login with the "next" get parameter
// set to the attempted URL.
func LoginRequired(r render.Render, user User, req *http.Request) {
if user.IsAuthenticated() == false {
path := fmt.Sprintf("/login?next=%s", req.URL.Path)
r.Redirect(path, 302)
}
}
示例14: HandleLogout
func HandleLogout(r render.Render, s sessions.Session) {
s.Delete("IsLogin")
r.Redirect("/admin/login")
}