GetLedger retrieves a ledger record by its ID. It extracts the ID from the route parameters and fetches the ledger record. If the ID is missing or there's an error retrieving the ledger, it responds with an appropriate error message. Parameters: - c: The Gin context containing the request and respo
(c *gin.Context)
| 69 | // - 400 Bad Request: If the ID is missing or there's an error retrieving the ledger. |
| 70 | // - 200 OK: If the ledger is successfully retrieved. |
| 71 | func (a Api) GetLedger(c *gin.Context) { |
| 72 | id, passed := c.Params.Get("id") |
| 73 | |
| 74 | if !passed { |
| 75 | c.JSON(http.StatusBadRequest, gin.H{"error": "id is required. Pass id in the route /:id"}) |
| 76 | return |
| 77 | } |
| 78 | |
| 79 | resp, err := a.ledgerforge.GetLedgerByID(id) |
| 80 | if err != nil { |
| 81 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 82 | return |
| 83 | } |
| 84 | |
| 85 | c.JSON(http.StatusOK, resp) |
| 86 | } |
| 87 | |
| 88 | // GetAllLedgers retrieves all ledger records in the system. |
| 89 | // It fetches the ledger records and responds with the list of ledgers. |
nothing calls this directly
no test coverage detected