//	演示form token的验证操作
func (s *SessionController) PostForm(context *leafveingo.HttpContext) string {
	if context.CheckFormToken() {
		return "form token check success."
	} else {
		return "form token check fail."
	}
}
func (c *TestRESTfulRouterController) Put(context *lv.HttpContext) interface{} {
	session, err := context.Session(false)
	if nil != err {
		return ""
	}
	return session.UID()
}
func (c *TestRESTfulRouterController) Post(context *lv.HttpContext) interface{} {
	params, err := context.PackStructForm((*RESTfulParam)(nil))
	if nil != err {
		return err.Error()
	}

	paramstruct := params.(*RESTfulParam)
	return lv.BodyJson(paramstruct)
}
//	演示form token的操作
func (s *SessionController) Form(context *leafveingo.HttpContext) leafveingo.HtmlOut {
	token := context.FormTokenHTML()

	html := `
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Form Token</title>
</head>
<body>
	尝试提交验证form token
	<br/>
	<form action="form.htm" method="post">
		` + token + `
	<input type="submit" value="提交">
	</form>
</body>
</html>
	`
	return leafveingo.BodyHtml(html)
}
//	上下文对session的操作
func (s *SessionController) Context(context *leafveingo.HttpContext) string {
	//	cookie token会在一定时间会自动重置,这里就不选择重置了。
	//	看需求而定是否需要重置。
	sess, err := context.Session(false)

	if nil != err {
		return fmt.Sprintf("session get error:%v", err.Error())
	}

	outString := ""

	name, ok := sess.Get("name")
	if !ok {
		//	测试存储数据
		sess.Set("name", "slowfei")
		outString = "Has not been set to the name, refreshed look."
	} else {
		outString = fmt.Sprintf("%v, welcome", name.(string))
	}

	return fmt.Sprintf("context get the session address: %p\n%v", sess, outString)
}