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

Method DetokenizeIdentityField

api/identity.go:285–306  ·  view source on GitHub ↗

DetokenizeIdentityField detokenizes a specific field in an identity. It extracts the identity ID and field name from the route parameters, detokenizes the field, and responds with the original value. Parameters: - c: The Gin context containing the request and response. Responses: - 400 Bad Request

(c *gin.Context)

Source from the content-addressed store, hash-verified

283// - 400 Bad Request: If the ID or field is missing, or there's an error detokenizing the field.
284// - 200 OK: If the field is successfully detokenized, returning the original value.
285func (a Api) DetokenizeIdentityField(c *gin.Context) {
286 id, idExists := c.Params.Get("id")
287 field, fieldExists := c.Params.Get("field")
288
289 if !idExists {
290 c.JSON(http.StatusBadRequest, gin.H{"error": "identity ID is required"})
291 return
292 }
293
294 if !fieldExists {
295 c.JSON(http.StatusBadRequest, gin.H{"error": "field name is required"})
296 return
297 }
298
299 originalValue, err := a.ledgerforge.DetokenizeIdentityField(id, field)
300 if err != nil {
301 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
302 return
303 }
304
305 c.JSON(http.StatusOK, gin.H{"field": field, "value": originalValue})
306}
307
308// TokenizeIdentity tokenizes multiple fields in an identity.
309// It binds the incoming JSON request containing the list of fields to tokenize,

Callers 1

DetokenizeIdentityMethod · 0.45

Calls 2

GetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected