[ci skip] more suggested improvements
This commit is contained in:
@@ -2,7 +2,6 @@ package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -62,24 +61,14 @@ func (h *Handler) SnapshotReportDownload(w http.ResponseWriter, r *http.Request)
|
||||
ctx := context.Background()
|
||||
tableName := r.URL.Query().Get("table")
|
||||
if tableName == "" {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
json.NewEncoder(w).Encode(map[string]string{
|
||||
"status": "ERROR",
|
||||
"message": "Missing table parameter",
|
||||
})
|
||||
writeJSONError(w, http.StatusBadRequest, "Missing table parameter")
|
||||
return
|
||||
}
|
||||
|
||||
reportData, err := report.CreateTableReport(h.Logger, h.Database, ctx, tableName)
|
||||
if err != nil {
|
||||
h.Logger.Error("Failed to create snapshot report", "error", err, "table", tableName)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
json.NewEncoder(w).Encode(map[string]string{
|
||||
"status": "ERROR",
|
||||
"message": fmt.Sprintf("Unable to create snapshot report: '%s'", err),
|
||||
})
|
||||
writeJSONError(w, http.StatusInternalServerError, fmt.Sprintf("Unable to create snapshot report: '%s'", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user