當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Render.Redirect方法代碼示例

本文整理匯總了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")
	}
}
開發者ID:lihex,項目名稱:vim-tips-web,代碼行數:8,代碼來源:admin.go

示例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")
}
開發者ID:lihex,項目名稱:vim-tips-web,代碼行數:9,代碼來源:admin_tips.go

示例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{})
}
開發者ID:lihex,項目名稱:vim-tips-web,代碼行數:12,代碼來源:admin.go

示例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")
}
開發者ID:lihex,項目名稱:vim-tips-web,代碼行數:15,代碼來源:admin_casts.go

示例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)
}
開發者ID:doct15,項目名稱:github-shields,代碼行數:8,代碼來源:main.go

示例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)
}
開發者ID:doct15,項目名稱:github-shields,代碼行數:8,代碼來源:main.go

示例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")
}
開發者ID:lihex,項目名稱:vim-tips-web,代碼行數:20,代碼來源:admin_casts.go

示例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")
	}
}
開發者ID:lihex,項目名稱:vim-tips-web,代碼行數:21,代碼來源:admin.go

示例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")
	}
}
開發者ID:slayer,項目名稱:logvoyage,代碼行數:17,代碼來源:middleware.go

示例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))
}
開發者ID:sc0rp1us,項目名稱:dotviz-server,代碼行數:7,代碼來源:dotviz.go

示例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("/")
	}
}
開發者ID:slayer,項目名稱:logvoyage,代碼行數:7,代碼來源:middleware.go

示例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")
}
開發者ID:lihex,項目名稱:vim-tips-web,代碼行數:6,代碼來源:admin_tips.go

示例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)
	}
}
開發者ID:rday,項目名稱:martini-login,代碼行數:10,代碼來源:sessionauth.go

示例14: HandleLogout

func HandleLogout(r render.Render, s sessions.Session) {
	s.Delete("IsLogin")
	r.Redirect("/admin/login")
}
開發者ID:lihex,項目名稱:vim-tips-web,代碼行數:4,代碼來源:admin.go


注:本文中的github.com/codegangsta/martini-contrib/render.Render.Redirect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。