MCPcopy
hub / github.com/superplanehq/superplane / handleWebSocket

Method handleWebSocket

pkg/public/server.go:1323–1359  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

1321}
1322
1323func (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
1362func (s *Server) setupDevProxy(webBasePath string) {

Callers

nothing calls this directly

Calls 7

GetUserFromContextFunction · 0.92
FindCanvasFunction · 0.92
InfofMethod · 0.80
ParseMethod · 0.80
ErrorfMethod · 0.80
NewClientMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected