summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsiddharth ravikumar <s@ricketyspace.net>2022-06-07 23:25:48 -0400
committersiddharth ravikumar <s@ricketyspace.net>2022-06-07 23:25:48 -0400
commitc0000090fd342f09b01bf677a255e74c3d400594 (patch)
tree1d8324f1677ef20608acd9b5c9f3da8639cefd83
parent2ac5b96ce7df6f3a6b6e90dc667f0a9d59e138d9 (diff)
main: update `showWeather`
Use `nws.GetForecastBundle`.
-rw-r--r--main.go23
1 files 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