add logs
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user