feat(api): add live collection contract endpoints

This commit is contained in:
Mikhail Chusavitin
2026-02-04 09:54:48 +03:00
parent 5a982d7ca8
commit aa3c82d9ba
4 changed files with 227 additions and 2 deletions

View File

@@ -28,12 +28,16 @@ type Server struct {
mu sync.RWMutex
result *models.AnalysisResult
detectedVendor string
collectMu sync.RWMutex
collectJobs map[string]*CollectJobStatusResponse
}
func New(cfg Config) *Server {
s := &Server{
config: cfg,
mux: http.NewServeMux(),
config: cfg,
mux: http.NewServeMux(),
collectJobs: make(map[string]*CollectJobStatusResponse),
}
s.setupRoutes()
return s
@@ -64,6 +68,9 @@ func (s *Server) setupRoutes() {
s.mux.HandleFunc("GET /api/export/txt", s.handleExportTXT)
s.mux.HandleFunc("DELETE /api/clear", s.handleClear)
s.mux.HandleFunc("POST /api/shutdown", s.handleShutdown)
s.mux.HandleFunc("POST /api/collect", s.handleCollectStart)
s.mux.HandleFunc("GET /api/collect/{id}", s.handleCollectStatus)
s.mux.HandleFunc("POST /api/collect/{id}/cancel", s.handleCollectCancel)
}
func (s *Server) Run() error {