Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/descrybe/descrybe-v2/apps/api/internal/platformsettings"
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
// POST /api/admin/settings/ai-roles/{role}/test — probe platform AI role credentials.
|
||||
// Mirrors mail/test: 200 with status ok|failed|skipped; never echoes secrets or upstream bodies.
|
||||
func (s *Server) handleAdminTestAIRole(w http.ResponseWriter, r *http.Request) {
|
||||
if s.AI == nil {
|
||||
Error(w, http.StatusServiceUnavailable, "ai provider unavailable")
|
||||
return
|
||||
}
|
||||
role := strings.TrimSpace(chi.URLParam(r, "role"))
|
||||
if role == "" || !platformsettings.ValidAIRole(role) {
|
||||
Error(w, http.StatusBadRequest, "unknown ai role (want processing|vectorization|docs_api|support)")
|
||||
return
|
||||
}
|
||||
result, err := s.AI.TestPlatformRole(r.Context(), role)
|
||||
if err != nil {
|
||||
// Safe message only — never echo provider error bodies (may contain key fragments).
|
||||
JSON(w, http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
JSON(w, http.StatusOK, result)
|
||||
}
|
||||
Reference in New Issue
Block a user