From 1f700deeb1a26ab289178b76518a33faa3f51545 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Sun, 4 Oct 2020 16:28:56 +0200 Subject: Be nice and tell the yr.no API who we are --- weather/weather.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/weather/weather.go b/weather/weather.go index d60e22c..87b7a83 100644 --- a/weather/weather.go +++ b/weather/weather.go @@ -37,7 +37,17 @@ type weatherdata struct { func CurrentWeather(place string) (Weather, error) { url := "http://www.yr.no/place/" + place + "/forecast_hour_by_hour.xml" - resp, err := http.Get(url) + + client := &http.Client{} + + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return Weather{}, err + } + + req.Header.Add("User-Agent", "github.com/slivasur/startpage/weather") + + resp, err := client.Do(req) if err != nil { return Weather{}, err } -- cgit v1.2.3-54-g00ecf