refactor: httpc package for easy to use (#1643)

This commit is contained in:
Kevin Wan
2022-03-14 20:15:14 +08:00
committed by GitHub
parent 09e6d94f9e
commit b5d1d8b0d1
3 changed files with 91 additions and 71 deletions

View File

@@ -21,10 +21,10 @@ func TestNamedService_Do(t *testing.T) {
func TestNamedService_Get(t *testing.T) {
svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
}))
service := NewService("foo")
resp, err := service.Get(svr.URL, func(cli *http.Client) {
service := NewService("foo", func(cli *http.Client) {
cli.Transport = http.DefaultTransport
})
resp, err := service.Get(svr.URL)
assert.Nil(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
}