-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Context option and Stats (#34)
* feat: add Context option * refactor: encapsulate HTTP method * feat: add Stats to Request * feat: add traceInterceptor with httptrace
- Loading branch information
Showing
7 changed files
with
205 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package requests | ||
|
||
import "net/http" | ||
|
||
// Get sends an HTTP request with GET method. | ||
// | ||
// On error, any Response can be ignored. A non-nil Response with a | ||
// non-nil error only occurs when Response.StatusCode() is not 2xx. | ||
func Get(url string, options ...Option) (*Response, error) { | ||
return callMethod(http.MethodGet, url, options...) | ||
} | ||
|
||
// Post sends an HTTP POST request. | ||
func Post(url string, options ...Option) (*Response, error) { | ||
return callMethod(http.MethodPost, url, options...) | ||
} | ||
|
||
// Put sends an HTTP request with PUT method. | ||
// | ||
// On error, any Response can be ignored. A non-nil Response with a | ||
// non-nil error only occurs when Response.StatusCode() is not 2xx. | ||
func Put(url string, options ...Option) (*Response, error) { | ||
return callMethod(http.MethodPut, url, options...) | ||
} | ||
|
||
// Patch sends an HTTP request with PATCH method. | ||
// | ||
// On error, any Response can be ignored. A non-nil Response with a | ||
// non-nil error only occurs when Response.StatusCode() is not 2xx. | ||
func Patch(url string, options ...Option) (*Response, error) { | ||
return callMethod(http.MethodPatch, url, options...) | ||
} | ||
|
||
// Delete sends an HTTP request with DELETE method. | ||
// | ||
// On error, any Response can be ignored. A non-nil Response with a | ||
// non-nil error only occurs when Response.StatusCode() is not 2xx. | ||
func Delete(url string, options ...Option) (*Response, error) { | ||
return callMethod(http.MethodDelete, url, options...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.