예제 #1
0
func main() {
	addr := flag.String("addr", ":8080", "address")
	flag.Parse()
	gomniauth.SetSecurityKey("key")
	gomniauth.WithProviders(
		github.New("clientid", "secretkey", "http://localhost:8080/auth/callback/github"),
	)

	http.HandleFunc("/1/0", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("hoge"))
	})
	http.Handle("/1/1", &templateHandler{filename: "chat.html"})

	http.Handle("/2/1", MustAuth(&templateHandler{filename: "chat.html"}))
	http.Handle("/login", &templateHandler{filename: "login.html"})
	http.HandleFunc("/auth", loginHandler)

	r := newRoom()
	r.tracer = trace.New(os.Stdout)
	http.Handle("/1/2", r)
	go r.run()

	if err := http.ListenAndServe(*addr, nil); err != nil {
		log.Fatal("ListenAndServe:", err)
	}
}
예제 #2
0
func main() {
	addr := flag.String("addr", ":8080", "address")
	flag.Parse()

	http.HandleFunc("/1/0", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("hoge"))
	})
	http.Handle("/1/1", &templateHandler{filename: "chat.html"})

	r := newRoom()
	r.tracer = trace.New(os.Stdout)
	http.Handle("/1/2", r)
	go r.run()

	if err := http.ListenAndServe(*addr, nil); err != nil {
		log.Fatal("ListenAndServe:", err)
	}
}