(w http.ResponseWriter, r *http.Request)
| 315 | } |
| 316 | |
| 317 | func (s *Server) handleSyncStatus(w http.ResponseWriter, r *http.Request) { |
| 318 | path := r.URL.Query().Get("path") |
| 319 | if path != "" { |
| 320 | expandedPath, err := s.expandPath(path) |
| 321 | if err != nil { |
| 322 | writeJSONError(w, http.StatusBadRequest, fmt.Sprintf("invalid path: %v", err), nil) |
| 323 | return |
| 324 | } |
| 325 | |
| 326 | db := s.store.FindDB(expandedPath) |
| 327 | if db == nil { |
| 328 | writeJSONError(w, http.StatusNotFound, "database not found", nil) |
| 329 | return |
| 330 | } |
| 331 | |
| 332 | writeJSON(w, http.StatusOK, SyncDiagnosticsResponse{ |
| 333 | Databases: []SyncDiagnostic{db.SyncDiagnostic()}, |
| 334 | }) |
| 335 | return |
| 336 | } |
| 337 | |
| 338 | dbs := s.store.DBs() |
| 339 | diagnostics := make([]SyncDiagnostic, 0, len(dbs)) |
| 340 | for _, db := range dbs { |
| 341 | diagnostics = append(diagnostics, db.SyncDiagnostic()) |
| 342 | } |
| 343 | writeJSON(w, http.StatusOK, SyncDiagnosticsResponse{Databases: diagnostics}) |
| 344 | } |
| 345 | |
| 346 | func writeJSON(w http.ResponseWriter, status int, v interface{}) { |
| 347 | w.Header().Set("Content-Type", "application/json") |
nothing calls this directly
no test coverage detected