Esempio n. 1
0
func main() {
	flag.Parse()

	m := mux.NewRouter()
	m.HandleFunc("/", Homepage)
	m.HandleFunc("/lucky/{name}", LuckyHandler)
	m.Handle("/grins.sh", xff.Handler(http.HandlerFunc(ScriptHandler)))
	m.Handle("/{owner}/{repo}/{ref}/{goos}/{arch}", xff.Handler(Gzip(http.HandlerFunc(BuildHandler))))

	log.Printf("Listening on *:%d", srvPort)
	http.ListenAndServe(":"+strconv.Itoa(srvPort), m)
}
Esempio n. 2
0
func main() {
	handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("hello from " + r.RemoteAddr + "\n"))
	})

	http.ListenAndServe(":3000", xff.Handler(handler))
}
Esempio n. 3
0
func main() {
	server := xff.Handler(handler())
	addr := fmt.Sprintf(":%d", *port)

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