Example #1
0
func init() {
	log.SetPrefix("webtoys ")
	log.SetFlags(log.LstdFlags)

	pastehere.Register(nil) // at /pastehere/
	webclock.Register(nil)  // at /webclock/
	irc.Register(nil)       // at /irc/
	err := weblibs.RegisterAll(nil)
	if err != nil {
		panic(err)
	}
}
Example #2
0
func StartServer(addr string, book *types.Book) error {
	parseTemplates()
	err := weblibs.RegisterAll(http.DefaultServeMux)
	if err != nil {
		return err
	}
	http.Handle("/", curryBook(book, pageHome))
	http.Handle("/account/", curryBook(book, pageAccount))
	http.Handle("/static/", http.StripPrefix("/static/",
		http.FileServer(http.Dir(StaticDir)),
	))
	log.Printf("starting HTTP server at %s", addr)
	return http.ListenAndServe(addr, nil)
}