(w http.ResponseWriter, r *http.Request)
| 1321 | } |
| 1322 | |
| 1323 | func (s *Server) handleWebSocket(w http.ResponseWriter, r *http.Request) { |
| 1324 | log.Infof("New WebSocket connection from %s", r.RemoteAddr) |
| 1325 | |
| 1326 | user, ok := middleware.GetUserFromContext(r.Context()) |
| 1327 | if !ok { |
| 1328 | http.Error(w, "Unauthorized", http.StatusUnauthorized) |
| 1329 | return |
| 1330 | } |
| 1331 | |
| 1332 | vars := mux.Vars(r) |
| 1333 | workflowID := vars["workflowId"] |
| 1334 | |
| 1335 | parsedWorkflowID, err := uuid.Parse(workflowID) |
| 1336 | if err != nil { |
| 1337 | http.Error(w, "workflow not found", http.StatusNotFound) |
| 1338 | return |
| 1339 | } |
| 1340 | |
| 1341 | _, err = models.FindCanvas(user.OrganizationID, parsedWorkflowID) |
| 1342 | if err != nil { |
| 1343 | http.Error(w, "canvas not found", http.StatusNotFound) |
| 1344 | return |
| 1345 | } |
| 1346 | |
| 1347 | ws, err := s.upgrader.Upgrade(w, r, nil) |
| 1348 | if err != nil { |
| 1349 | if _, ok := err.(websocket.HandshakeError); !ok { |
| 1350 | log.Println(err) |
| 1351 | } |
| 1352 | log.Errorf("Failed to upgrade to WebSocket: %v", err) |
| 1353 | return |
| 1354 | } |
| 1355 | |
| 1356 | client := s.wsHub.NewClient(ws, workflowID) |
| 1357 | |
| 1358 | <-client.Done |
| 1359 | } |
| 1360 | |
| 1361 | // setupDevProxy configures a simple reverse proxy to the Vite development server |
| 1362 | func (s *Server) setupDevProxy(webBasePath string) { |
nothing calls this directly
no test coverage detected