diff options
author | siddharth ravikumar <s@ricketyspace.net> | 2022-06-07 23:25:48 -0400 |
---|---|---|
committer | siddharth ravikumar <s@ricketyspace.net> | 2022-06-07 23:25:48 -0400 |
commit | c0000090fd342f09b01bf677a255e74c3d400594 (patch) | |
tree | 1d8324f1677ef20608acd9b5c9f3da8639cefd83 | |
parent | 2ac5b96ce7df6f3a6b6e90dc667f0a9d59e138d9 (diff) |
main: update `showWeather`
Use `nws.GetForecastBundle`.
-rw-r--r-- | main.go | 23 |
1 files changed, 6 insertions, 17 deletions
@@ -122,26 +122,15 @@ func main() { } func showWeather(w http.ResponseWriter, lat, lng float32) { - point, err := nws.Points(lat, lng) - if err != nil { - http.Error(w, err.Error(), 500) - return - } - - // Get forecast - f, err := nws.GetForecast(point) - if err != nil { - http.Error(w, err.Error(), 500) - return - } - fh, err := nws.GetForecastHourly(point) - if err != nil { - http.Error(w, err.Error(), 500) - return + forecastBundle, nwsErr := nws.GetForecastBundle(lat, lng) + if nwsErr != nil { + http.Error(w, nwsErr.Error(), nwsErr.Status) } // Make weather - weather, err := NewWeather(point, f, fh) + weather, err := NewWeather(forecastBundle.Point, + forecastBundle.Forecast, + forecastBundle.ForecastHourly) if err != nil { http.Error(w, err.Error(), 500) return |