Example #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))
}
Example #2
0
func (resp *TextResponse) Render(res *wcg.Response, req *wcg.Request) {
	res.WriteHeader(resp.StatusCode)
	res.WriteString(resp.Text)
	res.Close()
}
Example #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)...)
}
Example #4
0
func (resp *JSONResponse) Render(res *wcg.Response, req *wcg.Request) {
	res.WriteJSONWithStatus(resp.StatusCode, nil, resp.Data)
}