mirror of
https://github.com/TeamPiped/instances-api.git
synced 2024-08-14 23:57:19 +00:00
Send an identifiable user-agent.
This commit is contained in:
parent
b37ee94e52
commit
3cb46f1bac
1 changed files with 13 additions and 2 deletions
15
main.go
15
main.go
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue