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

Method RevokeAPIKey

api/apikeys.go:68–89  ·  view source on GitHub ↗

RevokeAPIKey revokes an API key Parameters: - c: The Gin context containing the request and response Responses: - 204 No Content: If the API key is successfully revoked - 404 Not Found: If the API key is not found - 403 Forbidden: If the user doesn't own the API key

(c *gin.Context)

Source from the content-addressed store, hash-verified

66// - 404 Not Found: If the API key is not found
67// - 403 Forbidden: If the user doesn't own the API key
68func (a Api) RevokeAPIKey(c *gin.Context) {
69 id := c.Param("id")
70 owner := c.Query("owner")
71 if owner == "" {
72 c.JSON(http.StatusUnauthorized, gin.H{"error": "unauthorized"})
73 return
74 }
75
76 if err := a.ledgerforge.RevokeAPIKey(c.Request.Context(), id, owner); err != nil {
77 switch err {
78 case database.ErrAPIKeyNotFound:
79 c.JSON(http.StatusNotFound, gin.H{"error": "API key not found"})
80 case database.ErrInvalidAPIKey:
81 c.JSON(http.StatusForbidden, gin.H{"error": "unauthorized"})
82 default:
83 c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
84 }
85 return
86 }
87
88 c.Status(http.StatusNoContent)
89}

Callers

nothing calls this directly

Calls 2

RevokeAPIKeyMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected