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


Golang Context.Redirect方法代碼示例

本文整理匯總了Golang中github.com/Cepave/grafana/pkg/middleware.Context.Redirect方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Redirect方法的具體用法?Golang Context.Redirect怎麽用?Golang Context.Redirect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/Cepave/grafana/pkg/middleware.Context的用法示例。


在下文中一共展示了Context.Redirect方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Logout

func Logout(c *middleware.Context) {
	c.SetCookie(setting.CookieUserName, "", -1, setting.AppSubUrl+"/")
	c.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubUrl+"/")
	c.SetCookie("sig", "", -1, setting.AppSubUrl+"/")
	c.Session.Destory(c)
	c.Redirect(setting.ConfigOpenFalcon.Login)
}
開發者ID:Cepave,項目名稱:grafana,代碼行數:7,代碼來源:login.go

示例2: LoginView

func LoginView(c *middleware.Context) {
	sig := c.GetCookie("sig")
	if len(sig) > 0 {
		c.Redirect(setting.AppSubUrl + "/")
		return
	} else {
		c.Redirect(setting.ConfigOpenFalcon.Login)
		return
	}

	if err := setIndexViewData(c); err != nil {
		c.Handle(500, "Failed to get settings", err)
		return
	}

	settings := c.Data["Settings"].(map[string]interface{})
	settings["googleAuthEnabled"] = setting.OAuthService.Google
	settings["githubAuthEnabled"] = setting.OAuthService.GitHub
	settings["disableUserSignUp"] = !setting.AllowUserSignUp

	if !tryLoginUsingRememberCookie(c) {
		c.HTML(200, VIEW_INDEX)
		return
	}

	if redirectTo, _ := url.QueryUnescape(c.GetCookie("redirect_to")); len(redirectTo) > 0 {
		c.SetCookie("redirect_to", "", -1, setting.AppSubUrl+"/")
		c.Redirect(redirectTo)
		return
	}

	c.Redirect(setting.AppSubUrl + "/")
}
開發者ID:Cepave,項目名稱:grafana,代碼行數:33,代碼來源:login.go

示例3: OverviewServer

func OverviewServer(c *middleware.Context) {
	host := c.Params(":host")
	url := "/dashboard/db/status?host=" + host
	c.Redirect(setting.AppSubUrl + url)
}
開發者ID:Cepave,項目名稱:grafana,代碼行數:5,代碼來源:chart.go

示例4: Net

/**
 * @function name:   func Net(c *middleware.Context)
 * @description:     This function redirects URL "/boss/net/:host" to net chart.
 * @related issues:  OWL-301
 * @param:           c *middleware.Context
 * @return:          void
 * @author:          Don Hsieh
 * @since:           01/27/2015
 * @last modified:   01/27/2015
 * @called by:       r.Get("/boss/net/:host", reqSignedIn, Net)
 *                    in grafana/pkg/api/api.go
 */
func Net(c *middleware.Context) {
	host := c.Params(":host")
	url := getUrl("net", host)
	c.Redirect(setting.AppSubUrl + url)
}
開發者ID:Cepave,項目名稱:grafana,代碼行數:17,代碼來源:chart.go


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