lot of new functionalities

This commit is contained in:
Arnaud Delcasse
2025-10-14 18:11:13 +02:00
parent a6f70a6e85
commit d992a7984f
164 changed files with 15113 additions and 9442 deletions

31
servers/web/api/export.go Normal file
View File

@@ -0,0 +1,31 @@
package api
import (
"encoding/csv"
"fmt"
"net/http"
"github.com/gorilla/mux"
"github.com/rs/zerolog/log"
)
func (h *Handler) CacheExport(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
cacheID := vars["cacheid"]
result, err := h.applicationHandler.ExportCacheAsCSV(cacheID)
if err != nil {
log.Error().Err(err).Msg("Error exporting cache")
w.WriteHeader(http.StatusNotFound)
return
}
w.Header().Set("Content-Type", "text/csv")
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=export-%s.csv", cacheID))
csvWriter := csv.NewWriter(w)
defer csvWriter.Flush()
csvWriter.Write(result.Headers)
csvWriter.WriteAll(result.Values)
}