From c0000090fd342f09b01bf677a255e74c3d400594 Mon Sep 17 00:00:00 2001 From: siddharth ravikumar Date: Tue, 7 Jun 2022 23:25:48 -0400 Subject: main: update `showWeather` Use `nws.GetForecastBundle`. --- main.go | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/main.go b/main.go index 6c8c442..0a86101 100644 --- a/main.go +++ b/main.go @@ -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 -- cgit v1.2.3