package api import ( "encoding/json" "net/http" ) // handleSchemaGet returns the per-field schema (recomputed from the store every // few minutes; see schema.Indexer). func (s *Server) handleSchemaGet(w http.ResponseWriter, r *http.Request) { if s.schemaIndexer == nil { http.Error(w, "schema indexer not running", http.StatusServiceUnavailable) return } snap := s.schemaIndexer.Snapshot() w.Header().Set("Content-Type", "application/json") _ = json.NewEncoder(w).Encode(snap) } // handleSchemaRescan recomputes the schema from a full scan of the store and // returns it. It no longer republishes every property into meta:events — the // indexer reads the store itself — so a rescan floods no consumer. func (s *Server) handleSchemaRescan(w http.ResponseWriter, r *http.Request) { if s.schemaIndexer == nil { http.Error(w, "schema indexer not running", http.StatusServiceUnavailable) return } snap, err := s.schemaIndexer.Rebuild(r.Context()) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } out := *snap out.Source = "rescan" w.Header().Set("Content-Type", "application/json") _ = json.NewEncoder(w).Encode(map[string]any{ "published_events": 0, "schema": &out, }) }