Send an identifiable user-agent.

This commit is contained in:
Kavin 2023-08-30 19:58:48 +01:00
parent b37ee94e52
commit 3cb46f1bac
No known key found for this signature in database
GPG key ID: 6E4598CA5C92C41F

15
main.go
View file

@ -61,7 +61,12 @@ var client = http.Client{
} }
func testUrl(url string) (*http.Response, error) { func testUrl(url string) (*http.Response, error) {
resp, err := client.Get(url) req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, err
}
req.Header.Set("User-Agent", "Piped-Instances-API/(https://github.com/TeamPiped/instances-api)")
resp, err := client.Do(req)
if err != nil { if err != nil {
return resp, err return resp, err
} }
@ -248,7 +253,13 @@ func monitorInstances() {
// do forever // do forever
for { for {
// send a request to get markdown from GitHub // send a request to get markdown from GitHub
resp, err := http.Get("https://raw.githubusercontent.com/wiki/TeamPiped/Piped-Frontend/Instances.md") req, err := http.NewRequest("GET", "https://raw.githubusercontent.com/wiki/TeamPiped/Piped-Frontend/Instances.md", nil)
if err != nil {
log.Print(err)
continue
}
req.Header.Set("User-Agent", "Piped-Instances-API/(https://github.com/TeamPiped/instances-api)")
resp, err := client.Do(req)
if err != nil { if err != nil {
log.Print(err) log.Print(err)
continue continue