コード例 #1
0
//doMotd simply renders motd file.
func doMotd(w http.ResponseWriter, r *http.Request) {
	f, err := ioutil.ReadFile(cfg.Motd())
	if err != nil {
		log.Println(err)
		return
	}
	fmt.Fprintf(w, string(f))
}
コード例 #2
0
//headApp renders motd(terms of service).
func (m *mchCGI) headApp() {
	m.WR.Header().Set("Content-Type", "text/plain; charset=Shift_JIS")
	var body string
	err := util.EachLine(cfg.Motd(), func(line string, i int) error {
		line = strings.TrimSpace(line)
		body += line + "<br>\n"
		return nil
	})
	if err != nil {
		log.Println(err)
	}
	m.serveContent("a.txt", time.Time{}, body)
}
コード例 #3
0
//printMotd renders motd.
func printMotd(w http.ResponseWriter, r *http.Request) {
	g, err := new(w, r)
	if err != nil {
		log.Println(err)
		return
	}

	g.WR.Header().Set("Content-Type", "text/plain; charset=UTF-8")
	c, err := ioutil.ReadFile(cfg.Motd())
	if err != nil {
		log.Println(err)
		return
	}
	_, err = g.WR.Write(c)
	if err != nil {
		log.Println(err)
	}
}