Esempio n. 1
0
// Benchmarks
func BenchmarkHttpJSON_CallWithRequiredArguments_Success(b *testing.B) {
	hm := gorpc.NewHandlersManager("github.com/sergei-svistunov/gorpc", gorpc.HandlersManagerCallbacks{})
	if err := hm.RegisterHandler(test_handler1.NewHandler()); err != nil {
		b.Fatal(err.Error())
	}

	handler := NewAPIHandler(hm, cache.NewMapCache(), APIHandlerCallbacks{})
	request, _ := http.NewRequest("GET", "/test/handler1/v1/?req_int=123", nil)
	recorder := httptest.NewRecorder()

	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		handler.ServeHTTP(recorder, request)
	}
}
Esempio n. 2
0
func (s *HttpJSONSute) SetupTest() {
	hm := gorpc.NewHandlersManager("github.com/sergei-svistunov/gorpc", gorpc.HandlersManagerCallbacks{})
	s.NoError(hm.RegisterHandler(test_handler1.NewHandler()))

	s.server = httptest.NewUnstartedServer(NewAPIHandler(hm, cache.NewMapCache(), APIHandlerCallbacks{}))
}