Exemplo n.º 1
0
func main() {
	mux := routes.New()
	mux.Get("/", ServeRandomCivAndRandomStrategy)
	mux.Get("/:civ", ServeCivAndRandomStrategy)
	mux.Get("/:civ/:strategy", ServeCivAndStrategy)

	http.Handle("/", mux)
	http.ListenAndServe(config.HostAndPort, nil)
}
// Benchmark_Routes runs a benchmark against our custom Mux using the
// default settings.
func Benchmark_Routes(b *testing.B) {

	handler := routes.New()
	handler.Get("/person/:last/:first", HandlerOk)

	for i := 0; i < b.N; i++ {
		r, _ := http.NewRequest("GET", "/person/anderson/thomas?learn=kungfu", nil)
		w := httptest.NewRecorder()
		handler.ServeHTTP(w, r)
	}

}