<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Request Data Dump</title>
<style type="text/css">
body{
	font-size: 14px;
}
h1{
	text-align: center;
	font-size: 1.5em;
}
hr{
	border: none;
	border-bottom: 1px solid #000000;
}
input{
	width: 500px;
}
table{
	width: 80%;
	margin: 10px auto;
	border-collapse: collapse;
}
th{
	background-color: #660066;
	color: #FFFFFF;
}
th, td{
	padding: 3px 10px;
	border: 1px solid #000000;
}
</style>
<script type="text/javascript">
function get() {
	var form = document.getElementById('mainform');
	form.method = 'GET';
	form.submit();
	return false;
}
function post() {
	var form = document.getElementById('mainform');
	form.method = 'POST';
	form.submit();
	return false;
}
</script>
</head>
<body>
<h1>请求数据回显</h1>

<hr />
<form action="dump" method="POST" id="mainform">
<table>
	<tr>
		<td>Name</td>
		<td><input type="text" name="name" value="{{.Form.Get "name"}}" /></td>
	</tr>
	<tr>
		<td>Age</td>
		<td><input type="text" name="age" value="{{.Form.Get "age"}}" /></td>
	</tr>
	<tr>
		<td>City</td>
		<td><input type="text" name="city" value="{{.Form.Get "city"}}" /></td>
	</tr>
	<tr>
		<td>Company</td>
		<td><input type="text" name="company" value="{{.Form.Get "company"}}" /></td>
	</tr>
	<tr>
		<td colspan="2">
			<button type="button" onclick="get();">GET Request</button>
			<button type="button" onclick="post();">POST Request</button>
		</td>
	</tr>
</table>
<hr />

<table>
	<tr>
		<th colspan="2">HEADER</th>
	</tr>
	{{range $k, $v := .Header}}
	<tr>
		<td>{{$k}}</td>
		<td>
		{{range $v}}
		{{.}}<br />
		{{end}}
		</td>
	</tr>
	{{end}}
</table>

<table>
	<tr>
		<th colspan="2">SERVER</th>
	</tr>
	<tr>
		<td>Server Address</td>
		<td>{{.Host}}</td>
	</tr>
	<tr>
		<td>Remote Address</td>
		<td>{{.RemoteAddr}}</td>
	</tr>
	<tr>
		<td>Protocol</td>
		<td>{{.Proto}}</td>
	</tr>
	<tr>
		<td>Request Method</td>
		<td>{{.Method}}</td>
	</tr>
	<tr>
		<td>Request URI</td>
		<td>{{.RequestURI}}</td>
	</tr>
	<tr>
		<td>Path</td>
		<td>{{.URL.Path}}</td>
	</tr>
	<tr>
		<td>RawQuery</td>
		<td>{{.URL.RawQuery}}</td>
	</tr>
</table>

<table>
	<tr>
		<th colspan="2">COOKIE</th>
	</tr>
	{{range .Cookies}}
	<tr>
		<td>{{.Name}}</td>
		<td>{{.Value}}</td>
	</tr>
	{{end}}
</table>

<table>
	<tr>
		<th colspan="2">REQUEST</th>
	</tr>
	{{range $k, $v := .Form}}
	<tr>
		<td>{{$k}}</td>
		<td>
		{{range $v}}
		{{.}}<br />
		{{end}}
		</td>
	</tr>
	{{end}}
</table>

<table>
	<tr>
		<th colspan="2">GET</th>
	</tr>
	{{range $k, $v := .URL.Query}}
	<tr>
		<td>{{$k}}</td>
		<td>
		{{range $v}}
		{{.}}<br />
		{{end}}
		</td>
	</tr>
	{{end}}
</table>

{{if and (eq .Method "POST") (eq "application/x-www-form-urlencoded" (.Header.Get "Content-Type"))}}
<table>
	<tr>
		<th colspan="2">POST</th>
	</tr>
	{{range $k, $v := .PostForm}}
	<tr>
		<td>{{$k}}</td>
		<td>
		{{range $v}}
		{{.}}<br />
		{{end}}
		</td>
	</tr>
	{{end}}
</table>
{{end}}
</body>
</html>
