Exemple #1
0
func (ph *PageHelper) NotFound(res *wcg.Response, req *wcg.Request) {
	res.TemplatesWithStatus(
		404,
		nil,
		"404.html", "header.html", "footer.html",
	)
}
Exemple #2
0
func (ph *PageHelper) Forbidden(res *wcg.Response, req *wcg.Request) {
	res.SetLocal("Ref", req.URL().RequestURI())
	res.TemplatesWithStatus(
		403,
		nil,
		"403.html", "header.html", "footer.html",
	)
}
Exemple #3
0
func (ph *PageHelper) InternalError(res *wcg.Response, req *wcg.Request, e error) {
	req.Logger.Error("Internal Server Error: %v", e)
	res.SetLocal("error", e)
	res.TemplatesWithStatus(
		500,
		nil,
		"500.html", "header.html", "footer.html",
	)
}
Exemple #4
0
func Redirect(res *wcg.Response, req *wcg.Request) {
	urlStr := req.Query("u")
	if urlobj, err := url.Parse(urlStr); err == nil && validateUrl(urlobj) {
		// TODO: Check blacklist
		res.Redirect(urlStr, 302)
		return
	}
	res.TemplatesWithStatus(
		404,
		nil,
		"404.html", "header.html", "footer.html",
	)
	return
}