List handles GET /alerts.
(w http.ResponseWriter, r *http.Request)
| 29 | |
| 30 | // List handles GET /alerts. |
| 31 | func (h *AlertsHandler) List(w http.ResponseWriter, r *http.Request) { |
| 32 | var assignedTo *string |
| 33 | if r.URL.Query().Get("assignedToMe") == "true" { |
| 34 | userID, _ := r.Context().Value(middleware.UserIDKey).(string) |
| 35 | if userID != "" { |
| 36 | assignedTo = &userID |
| 37 | } |
| 38 | } |
| 39 | alerts, err := h.alerts.List(r.Context(), assignedTo) |
| 40 | if err != nil { |
| 41 | Error(w, http.StatusInternalServerError, "Failed to fetch alerts") |
| 42 | return |
| 43 | } |
| 44 | successData(w, alerts) |
| 45 | } |
| 46 | |
| 47 | // GetStats handles GET /alerts/stats. |
| 48 | func (h *AlertsHandler) GetStats(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected