예제 #1
0
//	页面请求
func (p *ParamsController) Param6() interface{} {
	//	参数名设置注意查看input的name
	bodyHTML := `
<!doctype html>
<html>
	<meta charset="UTF-8">
	<head>
		<title>嵌套参数结构封装</title>
	</head>
	<body>
		<form action="param6.htm" method="post">
			<lable>用户ID</label>
			<input type="text" name="uid" value="1"/>
			<br/>

			<lable>用户名称</label>
			<input type="text" name="userName" value="slowfei"/>
			<br/>

			<lable>用户类型(name="type.typeName" 对应结构体的字段名称)</label>
			<input type="text" name="type.typeName" value="admin"/>
			<br/>

			<input type="submit" value="提交" />
		</form>
	</body>
</html>
	`
	// return leafveingo.Bodybyte([]byte(bodyHTML), true, "text/html; charset=utf-8", nil)
	return leafveingo.BodyHtml(bodyHTML)
}
예제 #2
0
// 输出text html, Content-Type = text/plain
func (r *ReturnParamController) Html() leafveingo.HtmlOut {
	html := `
		<!doctype html>
		<html lang="en">
		<head>
			<meta charset="UTF-8">
			<title>Document</title>
		</head>
		<body>
			<h1>Hello world</h1>
		</body>
		</html>
	`
	return leafveingo.BodyHtml(html)
}
예제 #3
0
//	重定向url
func (r *ReturnParamController) Redirect(params struct {
	Url string
}) interface{} {
	if 0 == len(params.Url) {
		return leafveingo.BodyHtml(`
			<!doctype html>
			<html lang="en">
			<head>
				<meta charset="UTF-8">
				<title>Redirect</title>
			</head>
			<body>
				<a href="/r/redirect?url=https://github.com/slowfei">Redirect to github.com/slowfei</a>
			</body>
			</html>
			`)
	} else {
		return leafveingo.BodyRedirect(params.Url)
	}
}
예제 #4
0
//	演示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)
}
예제 #5
0
//	页面请求
func (p *ParamsController) Param7() leafveingo.HtmlOut {
	//	参数名设置注意查看input的name
	bodyHTML := `
<!doctype html>
<html>
	<meta charset="UTF-8">
	<head>
		<title>嵌套参数结构封装</title>
	</head>
	<body>
		<form action="param7.htm" method="post">
			<h3>用户1</h3>
			<lable>用户ID(name="users[0].uid"): 用户名称(name="users[0].userName"): 用户类型(name="users[0].type.typeName")</label>
			<br/>
			<input type="text" name="users[0].uid" value="1"/>
			<input type="text" name="users[0].userName" value="slowfei_1"/>
			<input type="text" name="users[0].type.typeName" value="admin"/>
			<br/>
			<label>兴趣爱好(name="users[0].interest[0]")</label>
			<br/>
			<input type="text" name="users[0].interest[0]" value="1_爱好1"/>
			<input type="text" name="users[0].interest[1]" value="1_爱好2"/>
			<input type="text" name="users[0].interest[2]" value="1_爱好3"/>
			<br/>

			<h3>用户2</h3>
			<lable>用户ID(name="users[1].uid"): 用户名称(name="users[1].userName"): 用户类型(name="users[1].type.typeName")</label>
			<br/>
			<input type="text" name="users[1].uid" value="2"/>
			<input type="text" name="users[1].userName" value="slowfei_2"/>
			<input type="text" name="users[1].type.typeName" value="admin"/>
			<br/>
			<label>兴趣爱好(name="users[1].interest[0]")</label>
			<br/>
			<input type="text" name="users[1].interest[0]" value="2_爱好1"/>
			<input type="text" name="users[1].interest[1]" value="2_爱好2"/>
			<input type="text" name="users[1].interest[2]" value="2_爱好3"/>
			<br/>
			
			<h3>用户3</h3>
			<lable>用户ID(name="users[2].uid"): 用户名称(name="users[2].userName"): 用户类型(name="users[2].type.typeName")</label>
			<br/>
			<input type="text" name="users[2].uid" value="3"/>
			<input type="text" name="users[2].userName" value="slowfei_3"/>
			<input type="text" name="users[2].type.typeName" value="admin"/>
			<br/>
			<label>兴趣爱好(name="users[2].interest[0]")</label>
			<br/>
			<input type="text" name="users[2].interest[0]" value="3_爱好1"/>
			<input type="text" name="users[2].interest[1]" value="3_爱好2"/>
			<input type="text" name="users[2].interest[2]" value="3_爱好3"/>
			<br/>

			<h3>Tags</h3>
			tags1(name="tags"):
			<input type="checkbox" name="tags" value="tags1">
			tags2(name="tags"):
			<input type="checkbox" name="tags" value="tags2">
			tags3(name="tags"):
			<input type="checkbox" name="tags" value="tags3">
			<br/>

			<input type="submit" value="提交" />
		</form>
	</body>
</html>
	`

	return leafveingo.BodyHtml(bodyHTML)
}