Skip to content

Commit

Permalink
Update xutil
Browse files Browse the repository at this point in the history
  • Loading branch information
onanying committed Sep 11, 2023
1 parent 8eac2ed commit 09a63f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ go get github.com/mix-go/xutil
| Function | Description |
|----------------------------------------------------------------------------------|----------------------------------|
| xhttp.Request(method string, u string, opts ...RequestOption) (*Response, error) | Execute an http request. |
| xhttp.Do(req *http.Request, opts ...RequestOption) (*Response, error) | Execute an http request. |
| xhttp.WithBody(body Body) RequestOption | Set configuration item |
| xhttp.WithHeader(header http.Header) RequestOption | Set configuration item |
| xhttp.WithContentType(contentType string) RequestOption | Set configuration item |
Expand Down
10 changes: 10 additions & 0 deletions xhttp/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,13 @@ func Request(method string, u string, opts ...RequestOption) (*Response, error)
resp := newResponse(r)
return resp, err
}

func Do(req *http.Request, opts ...RequestOption) (*Response, error) {
opt := getOptions(opts)
cli := http.Client{
Timeout: opt.Timeout,
}
r, err := cli.Do(req)
resp := newResponse(r)
return resp, err
}

0 comments on commit 09a63f0

Please sign in to comment.