package api import ( "encoding/json" "net/http" "github.com/google/uuid" "github.com/jackc/pgx/v5/pgtype" ) func (a *API) ListRepositoriesHandler(w http.ResponseWriter, r *http.Request) { tenantIDStr := r.URL.Query().Get("tenant_id") tenantID, err := uuid.Parse(tenantIDStr) if err != nil { http.Error(w, "Invalid tenant_id", http.StatusBadRequest) return } repos, err := a.queries.ListRepositoriesByTenant(r.Context(), pgtype.UUID{Bytes: tenantID, Valid: true}) if err != nil { http.Error(w, "Failed to list repositories", http.StatusInternalServerError) return } w.Header().Set("Content-Type", "application/json") if err := json.NewEncoder(w).Encode(repos); err != nil { http.Error(w, "Failed to encode response", http.StatusInternalServerError) } }