MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / HandleDeleteAPIKey

Method HandleDeleteAPIKey

internal/auth/auth.go:844–864  ·  view source on GitHub ↗

HandleDeleteAPIKey deletes an API key owned by the authenticated user.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

842
843// HandleDeleteAPIKey deletes an API key owned by the authenticated user.
844func (ua *UserAuth) HandleDeleteAPIKey(w http.ResponseWriter, r *http.Request) {
845 user := ua.AuthenticateRequest(r)
846 if user == nil {
847 http.Error(w, "not authenticated", http.StatusUnauthorized)
848 return
849 }
850
851 path := strings.TrimPrefix(r.URL.Path, "/api/keys/")
852 keyID := path
853 if keyID == "" {
854 http.Error(w, "key id required", http.StatusBadRequest)
855 return
856 }
857
858 if err := ua.store.DeleteAPIKey(r.Context(), keyID, user.ID); err != nil {
859 http.Error(w, err.Error(), http.StatusNotFound)
860 return
861 }
862
863 w.WriteHeader(http.StatusOK)
864}

Callers

nothing calls this directly

Calls 4

AuthenticateRequestMethod · 0.95
DeleteAPIKeyMethod · 0.80
ErrorMethod · 0.45
WriteHeaderMethod · 0.45

Tested by

no test coverage detected