Ejemplo n.º 1
0
func setupNamedSizesServer() func(string, string) *httptest.ResponseRecorder {
	router := mux.NewRouter()
	imgSrv := th.SetupImgServer()
	srv := btcdn.NewNamedSizesServer(imgSrv, router)

	return func(method, path string) *httptest.ResponseRecorder {
		rec := httptest.NewRecorder()
		req, err := http.NewRequest(method, "http://example.com"+path, nil)

		if err != nil {
			log.Fatal(err)
		}

		srv.ServeHTTP(rec, req)

		return rec
	}
}
Ejemplo n.º 2
0
func setupCachedEndpoint() func(string, string) *httptest.ResponseRecorder {
	router := mux.NewRouter()
	imgSrv := th.SetupImgServer()
	cached := btcdn.NewCachedEndpoint(imgSrv, "../fixtures/test")
	named := btcdn.NewNamedSizesServer(cached, router)

	return func(method, path string) *httptest.ResponseRecorder {
		rec := httptest.NewRecorder()
		req, err := http.NewRequest(method, "http://example.com"+path, nil)

		if err != nil {
			log.Fatal(err)
		}

		named.ServeHTTP(rec, req)

		return rec
	}
}