GetBalanceMonitor retrieves a balance monitor record by its ID. It extracts the ID from the route parameters. If the ID is missing or there's an error retrieving the monitor, it responds with an appropriate error message. Parameters: - c: The Gin context containing the request and response. Respon
(c *gin.Context)
| 234 | // - 400 Bad Request: If the ID is missing or there's an error retrieving the balance monitor. |
| 235 | // - 200 OK: If the balance monitor is successfully retrieved. |
| 236 | func (a Api) GetBalanceMonitor(c *gin.Context) { |
| 237 | id, passed := c.Params.Get("id") |
| 238 | if !passed { |
| 239 | c.JSON(http.StatusBadRequest, gin.H{"error": "id is required. pass id in the route /:id"}) |
| 240 | return |
| 241 | } |
| 242 | |
| 243 | resp, err := a.ledgerforge.GetMonitorByID(c.Request.Context(), id) |
| 244 | if err != nil { |
| 245 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 246 | return |
| 247 | } |
| 248 | |
| 249 | c.JSON(http.StatusOK, resp) |
| 250 | } |
| 251 | |
| 252 | // GetAllBalanceMonitors retrieves all balance monitor records in the system. |
| 253 | // It fetches the monitor records and responds with the list of monitors. |
nothing calls this directly
no test coverage detected