diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2020-10-04 16:28:56 +0200 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2020-10-04 16:28:56 +0200 |
commit | 1f700deeb1a26ab289178b76518a33faa3f51545 (patch) | |
tree | adf1997cd8609ebb371dae7b1290e99614bb71f0 | |
parent | a94847108155dbdec4813dafb0c2abe0bfbb90b1 (diff) | |
download | startpage-1f700deeb1a26ab289178b76518a33faa3f51545.tar.gz startpage-1f700deeb1a26ab289178b76518a33faa3f51545.tar.bz2 startpage-1f700deeb1a26ab289178b76518a33faa3f51545.zip |
Be nice and tell the yr.no API who we are
-rw-r--r-- | weather/weather.go | 12 |
1 files changed, 11 insertions, 1 deletions
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 } |