Init
This commit is contained in:
24
pixelapi/request.go
Normal file
24
pixelapi/request.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package pixelapi
|
||||
|
||||
import "net/http"
|
||||
import "io/ioutil"
|
||||
|
||||
func get(url string) (string, error) {
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
client := &http.Client{}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
bodyBytes, err := ioutil.ReadAll(resp.Body)
|
||||
|
||||
return string(bodyBytes), err
|
||||
}
|
Reference in New Issue
Block a user