DeleteIdentity deletes an existing identity record by its ID. It extracts the ID from the route parameters and deletes the record. If the ID is missing or there's an error deleting the identity, it responds with an appropriate error message. Parameters: - c: The Gin context containing the request a
(c *gin.Context)
| 124 | // - 400 Bad Request: If the ID is missing or there's an error deleting the identity. |
| 125 | // - 200 OK: If the identity is successfully deleted. |
| 126 | func (a Api) DeleteIdentity(c *gin.Context) { |
| 127 | id, passed := c.Params.Get("id") |
| 128 | if !passed { |
| 129 | c.JSON(http.StatusBadRequest, gin.H{"error": "id is required. pass id in the route /:id"}) |
| 130 | return |
| 131 | } |
| 132 | |
| 133 | err := a.ledgerforge.DeleteIdentity(id) |
| 134 | if err != nil { |
| 135 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 136 | return |
| 137 | } |
| 138 | |
| 139 | c.JSON(http.StatusOK, gin.H{"message": "Identity deleted successfully"}) |
| 140 | } |
| 141 | |
| 142 | // GetAllIdentities retrieves all identity records in the system. |
| 143 | // It fetches the identity records and responds with the list of identities. |
nothing calls this directly
no test coverage detected