Esempio n. 1
0
func Subscribe(w http.ResponseWriter, r *http.Request) *templates.HttpResponse {
	writeLock.Lock()
	defer writeLock.Unlock()

	params := map[string]interface{}{}
	good := false

	if f, err := os.OpenFile(config.String("storage.file"), os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666); nil == err {
		r.ParseForm()
		if email := strings.TrimSpace(r.Form.Get("email")); len(email) > 0 {
			_, err := f.WriteString(email + "\n")
			good = nil == err
		}
		f.Close()
	}

	if good {
		params["good"] = true
	} else {
		params["error"] = true
	}

	return templates.Response(200, "index.html", params)
}
Esempio n. 2
0
func Index(w http.ResponseWriter, r *http.Request) *templates.HttpResponse {
	return templates.Response(200, "index.html", nil)
}