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

This commit is contained in:
Kevin Wan
2022-03-15 14:18:46 +08:00
committed by GitHub
parent b5d1d8b0d1
commit f9e6013a6c
4 changed files with 24 additions and 22 deletions

View File

@@ -6,16 +6,16 @@ import (
)
// Do sends an HTTP request to the service assocated with the given key.
func Do(key string, r *http.Request, opts ...Option) (*http.Response, error) {
return NewService(key, opts...).Do(r)
func Do(key string, r *http.Request) (*http.Response, error) {
return NewService(key).Do(r)
}
// Get sends an HTTP GET request to the service assocated with the given key.
func Get(key, url string, opts ...Option) (*http.Response, error) {
return NewService(key, opts...).Get(url)
func Get(key, url string) (*http.Response, error) {
return NewService(key).Get(url)
}
// Post sends an HTTP POST request to the service assocated with the given key.
func Post(key, url, contentType string, body io.Reader, opts ...Option) (*http.Response, error) {
return NewService(key, opts...).Post(url, contentType, body)
func Post(key, url, contentType string, body io.Reader) (*http.Response, error) {
return NewService(key).Post(url, contentType, body)
}