requests.Configure, requests.TestServer, Builder.BaseURL #71
-
There's an unmerged branch with a top level requests.Configure function: 6cbe79c. I never merged it because there's not a good way to set the base URL for a request. I don't want there to be two redundant ways of setting the base URL, so requests.URL is the only way to set a Builder's base URL. But now I'm thinking I want something that can take a httptest.Server and use its client and base URL. So maybe I should bring that branch back, add a Builder.BaseURL method and then have ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello, client")
}))
defer ts.Close()
var s string
err = requests.
Configure(requests.TestServer(ts)).
Path("/test-endpoint").
ToString(&s).
Fetch(context.Background())
be.NilErr(t, err)
be.Equal(t, "Hello, client", s) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Done in #72. |
Beta Was this translation helpful? Give feedback.
Done in #72.