generated from bing/readnotes
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
|
package curl
|
||
|
|
||
|
import "net/http"
|
||
|
|
||
|
type CURL interface {
|
||
|
DoRequest(string, string, interface{}, http.Header) (*http.Response, error)
|
||
|
DoRequestReturnBytes(string, string, interface{}, http.Header) ([]byte, error)
|
||
|
Get(string, interface{}, http.Header) ([]byte, error)
|
||
|
Put(string, interface{}, http.Header) ([]byte, error)
|
||
|
Post(string, interface{}, http.Header) ([]byte, error)
|
||
|
Delete(string, interface{}, http.Header) ([]byte, error)
|
||
|
Patch(string, interface{}, http.Header) ([]byte, error)
|
||
|
}
|
||
|
|
||
|
var curl CURL
|
||
|
|
||
|
func init() {
|
||
|
curl = V1(http.Header{})
|
||
|
}
|
||
|
|
||
|
func DoRequest(method, url string, body interface{}, header http.Header) (*http.Response, error) {
|
||
|
return curl.DoRequest(method, url, body, header)
|
||
|
}
|
||
|
|
||
|
func DoRequestReturnBytes(method, url string, body interface{}, header http.Header) ([]byte, error) {
|
||
|
return curl.DoRequestReturnBytes(method, url, body, header)
|
||
|
}
|
||
|
|
||
|
func Get(url string, body interface{}, header http.Header) ([]byte, error) {
|
||
|
return curl.Get(url, body, header)
|
||
|
}
|
||
|
|
||
|
func Put(url string, body interface{}, header http.Header) ([]byte, error) {
|
||
|
return curl.Put(url, body, header)
|
||
|
}
|
||
|
|
||
|
func Post(url string, body interface{}, header http.Header) ([]byte, error) {
|
||
|
return curl.Post(url, body, header)
|
||
|
}
|
||
|
|
||
|
func Patch(url string, body interface{}, header http.Header) ([]byte, error) {
|
||
|
return curl.Patch(url, body, header)
|
||
|
}
|
||
|
|
||
|
func Delete(url string, body interface{}, header http.Header) ([]byte, error) {
|
||
|
return curl.Delete(url, body, header)
|
||
|
}
|
||
|
|
||
|
func SimpleGet(url string) ([]byte, error) {
|
||
|
return curl.Get(url, nil, nil)
|
||
|
}
|