Exemple #1
0
func requestInit(pSapi *sapi.Sapi, plugin interface{}) error {
	var action, uri string
	var rewriteParam map[string]string

	param := pSapi.Plugin("httpparam").(*httpparam.Param)
	_, ok := param.Get["r"]
	uri = strings.TrimSpace(pSapi.RequestURI())

	if !ok {
		if uri == "" || uri == "/" {
			action = confDefaultAction
		} else if confEnableRewrite {
			action, rewriteParam = urlToAction(pSapi.RequestURI())
			if len(rewriteParam) > 0 {
				for k, v := range rewriteParam {
					param.Get.Set(k, v)
				}
			}
		}
	} else {
		action = param.Get.Get("r")
		if action == "" {
			action = confDefaultAction
		}
	}

	pSapi.SetActionName(action)
	return nil
}
Exemple #2
0
//request-bootstrap操作
func appRequestInit(sapi *sapi.Sapi, plugin interface{}) error {
	sess := sapi.Plugin("session").(*session.Session)
	sess.Start()
	uname := sess.Get("uname").(string)

	view := sapi.Plugin("view").(*view.View)
	view.Assign("siteName", "wgf Demo")
	view.Assign("sessionUname", uname)
	view.Assign("urlLogout", sapi.Plugin("router").(*router.Router).Url("logout", nil))
	return nil
}