Exemple #1
0
func (re *Redirect) Render(res *wcg.Response, req *wcg.Request) {
	url := re.URL
	if !strings.HasPrefix(url, "http://") && strings.HasPrefix(url, "https://") {
		url = wcg.AbsoluteURL(req, url)
	}
	res.Redirect(url, int(re.StatusCode))
}
Exemple #2
0
func (resp *TextResponse) Render(res *wcg.Response, req *wcg.Request) {
	res.WriteHeader(resp.StatusCode)
	res.WriteString(resp.Text)
	res.Close()
}
Exemple #3
0
func (pr *PageResponse) Render(res *wcg.Response, req *wcg.Request) {
	res.SetLocal("Request", req)
	res.SetLocal("SiteConfig", generateSiteConfigs(req))
	res.SetLocal("CSRFToken", generateCSRFToken(req))
	res.SetLocal("Page", pr)
	res.SetLocal("StaticTimestamp", wcg.FormatDateTime(lib.StartTime))
	res.TemplatesWithStatus(pr.StatusCode, nil, pr.GetTemplates(req)...)
}
Exemple #4
0
func (resp *JSONResponse) Render(res *wcg.Response, req *wcg.Request) {
	res.WriteJSONWithStatus(resp.StatusCode, nil, resp.Data)
}