neko/server/pkg/utils/request.go
2024-06-23 17:48:14 +02:00

23 lines
309 B
Go

package utils
import (
"bytes"
"io"
"net/http"
)
func HttpRequestGET(url string) (string, error) {
rsp, err := http.Get(url)
if err != nil {
return "", err
}
defer rsp.Body.Close()
buf, err := io.ReadAll(rsp.Body)
if err != nil {
return "", err
}
return string(bytes.TrimSpace(buf)), nil
}