summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaria Carolin Chabowski <laria@laria.me>2020-10-04 16:28:56 +0200
committerLaria Carolin Chabowski <laria@laria.me>2020-10-04 16:28:56 +0200
commit1f700deeb1a26ab289178b76518a33faa3f51545 (patch)
treeadf1997cd8609ebb371dae7b1290e99614bb71f0
parenta94847108155dbdec4813dafb0c2abe0bfbb90b1 (diff)
downloadstartpage-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.go12
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
}