summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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