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

Method CreateIdentity

api/identity.go:39–53  ·  view source on GitHub ↗

CreateIdentity creates a new identity record in the system. It binds the incoming JSON request to an Identity object, validates it, and then creates the identity record. If any errors occur during validation or creation, it responds with an appropriate error message. Parameters: - c: The Gin contex

(c *gin.Context)

Source from the content-addressed store, hash-verified

37// - 400 Bad Request: If there's an error in binding JSON or creating the identity.
38// - 201 Created: If the identity is successfully created.
39func (a Api) CreateIdentity(c *gin.Context) {
40 var identity model.Identity
41 if err := c.ShouldBindJSON(&identity); err != nil {
42 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
43 return
44 }
45
46 resp, err := a.ledgerforge.CreateIdentity(identity)
47 if err != nil {
48 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
49 return
50 }
51
52 c.JSON(http.StatusCreated, resp)
53}
54
55// GetIdentity retrieves an identity record by its ID.
56// It extracts the ID from the route parameters and fetches the identity record.

Callers

nothing calls this directly

Calls 2

CreateIdentityMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected