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 } }
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 } }