MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / GetLedger

Method GetLedger

api/ledger.go:71–86  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
71func (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.

Callers

nothing calls this directly

Calls 3

GetMethod · 0.65
GetLedgerByIDMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected