This commit is contained in:
2026-02-18 16:21:47 -08:00
parent b49349eb26
commit 9150a069fe
5 changed files with 6 additions and 77 deletions
+4 -1
View File
@@ -2,6 +2,7 @@ package handlers
import (
"encoding/json"
"fmt"
"go-weather/services"
"net/http"
)
@@ -42,7 +43,7 @@ func (h *WeatherHandler) FetchWeather(w http.ResponseWriter, r *http.Request) {
return
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]interface{}{
json.NewEncoder(w).Encode(map[string]any{
"message": "weather fetched and saved",
"id": id,
"city": weather.Name,
@@ -60,6 +61,8 @@ func (h *WeatherHandler) GetHistory(w http.ResponseWriter, r *http.Request) {
city = h.config.DefaultCity
}
readings, err := h.dbService.GetReadings(city, 25)
fmt.Printf("Length of readings: %v", len(readings))
fmt.Printf("HELLO")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return