Esempio n. 1
0
func flag(w http.ResponseWriter, req *http.Request, img string, ctxt *fs.Context) {
	if !isImgName(img) && !isTagName(img) {
		fmt.Fprintf(w, "Invalid image.\n")
		return
	}
	data, _, _ := ctxt.Read("qr/flag/" + img)
	data = append(data, '!')
	ctxt.Write("qr/flag/"+img, data)

	fmt.Fprintf(w, "Thank you.  The image has been reported.\n")
}
Esempio n. 2
0
func runTemplate(c *fs.Context, w http.ResponseWriter, name string, data interface{}) {
	t := template.New("main")

	main, _, err := c.Read(name)
	if err != nil {
		panic(err)
	}
	style, _, _ := c.Read("style.html")
	main = append(main, style...)
	_, err = t.Parse(string(main))
	if err != nil {
		panic(err)
	}

	var buf bytes.Buffer
	if err := t.Execute(&buf, &data); err != nil {
		panic(err)
	}
	w.Write(buf.Bytes())
}