mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-13 13:38:16 +08:00
Initial commit
This commit is contained in:
29
provider/http.go
Normal file
29
provider/http.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"github.com/go-resty/resty/v2"
|
||||
"time"
|
||||
)
|
||||
|
||||
func httpGet(url string, header map[string]string) (*resty.Response, error) {
|
||||
resp, err := resty.New().
|
||||
SetTimeout(time.Second * 3).R().
|
||||
SetHeaders(header).
|
||||
Get(url)
|
||||
return resp, err
|
||||
}
|
||||
func httpGetString(url string, header map[string]string) string {
|
||||
resp, err := httpGet(url, header)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return resp.String()
|
||||
}
|
||||
|
||||
func httpHead(url string, header map[string]string) (*resty.Response, error) {
|
||||
resp, err := resty.New().
|
||||
SetTimeout(time.Second * 3).R().
|
||||
SetHeaders(header).
|
||||
Head(url)
|
||||
return resp, err
|
||||
}
|
||||
Reference in New Issue
Block a user