cleanup
This commit is contained in:
+4
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user