예제 #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
	}
}
예제 #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
	}
}