This commit is contained in:
2025-10-28 23:39:13 +01:00
parent b38e77218e
commit 5560fad92e
3 changed files with 15 additions and 7 deletions
+8 -1
View File
@@ -70,6 +70,7 @@ func (h *Handler) IngestCSV(w http.ResponseWriter, r *http.Request) {
"elapsed_ms", fileStats.ElapsedMS,
"file_checksum", fileStats.FileChecksum,
)
h.ToJSON(w, http.StatusOK, app.H{"stats": fileStats})
}
@@ -77,6 +78,9 @@ func (h *Handler) IngestExcel(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "hello from excel")
}
func (h *Handler) GetCities(w http.ResponseWriter, r *http.Request) {
}
func (h *Handler) GetMeteoData(w http.ResponseWriter, r *http.Request) {
queryParams := r.URL.Query()
@@ -89,16 +93,19 @@ func (h *Handler) GetMeteoData(w http.ResponseWriter, r *http.Request) {
}
if err := params.Validate(); err != nil {
slog.Error("Error validating struct", "error", err)
h.ToJSON(w, http.StatusBadRequest, app.H{"error": err.Error()})
return
}
meteoData, err := h.s.GetMeteoData(r.Context(), params)
if err != nil {
slog.Error(ErrReadingData.Error(), "error", err)
h.ToJSON(w, http.StatusNotFound, app.H{"error": ErrReadingData.Error()})
return
}
slog.Info("Data retrieved", "location", params.Location)
h.ToJSON(w, http.StatusOK, app.H{"meteo_data": meteoData})
return
}