Add self-info endpoint for ProjectConfigurator discovery, sync shared updates
GET /api/info reports name/tabs/mount types (empty - state lives in Postgres, no shared file mounts) so ProjectConfigurator's Projects workspace can register this instance from just a URL. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
557a61b4ee
commit
bbf5d8bb05
126 files changed
+2897
-8542
No files matched your search
@@ -131,6 +131,7 @@ func connectWithRetry(ctx context.Context, connectionString string) (*DB, error)
|
||||
func (s *Server) registerRoutes(mux *http.ServeMux, webRoot fs.FS) {
|
||||
// Health and auth bootstrap routes are intentionally public.
|
||||
mux.HandleFunc("GET /health", s.handleHealth)
|
||||
mux.HandleFunc("GET /api/info", s.handleInfo)
|
||||
mux.HandleFunc("GET /api/auth/status", s.auth.handleStatus)
|
||||
mux.HandleFunc("POST /api/auth/setup", s.auth.handleSetup)
|
||||
mux.HandleFunc("POST /api/auth/login", s.auth.handleLogin)
|
||||
@@ -188,6 +189,23 @@ func (s *Server) handleHealth(w http.ResponseWriter, _ *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
// handleInfo is CollabTable's self-describe endpoint: ProjectConfigurator's Projects workspace
|
||||
// calls this (via its server-side /api/discover-service proxy) when an operator adds CollabTable
|
||||
// by URL, to populate its display name, navigable tabs, and mount path types (none - CollabTable
|
||||
// keeps all of its data in PostgreSQL, with no shared file mounts of its own) without any manual
|
||||
// entry.
|
||||
func (s *Server) handleInfo(w http.ResponseWriter, _ *http.Request) {
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
"ok": true,
|
||||
"name": "CollabTable",
|
||||
"tabs": []map[string]string{
|
||||
{"label": "Overview", "token": "/"},
|
||||
{"label": "About", "token": "/about"},
|
||||
},
|
||||
"mountTypes": []string{},
|
||||
})
|
||||
}
|
||||
|
||||
func envOrDefault(name, fallback string) string {
|
||||
if value := strings.TrimSpace(os.Getenv(name)); value != "" {
|
||||
return value
|
||||
|
||||
Reference in new issue
Block a user