validateJSONRPCTransportConsistency validates JSON-RPC transport combinations. WebSocket cannot be mixed with other transports, but HTTP and SSE can coexist.
(verr *eval.ValidationErrors)
| 400 | // validateJSONRPCTransportConsistency validates JSON-RPC transport combinations. |
| 401 | // WebSocket cannot be mixed with other transports, but HTTP and SSE can coexist. |
| 402 | func (svc *HTTPServiceExpr) validateJSONRPCTransportConsistency(verr *eval.ValidationErrors) { |
| 403 | var hasWebSocket, hasSSE, hasRegular bool |
| 404 | |
| 405 | for _, e := range svc.HTTPEndpoints { |
| 406 | if e.IsJSONRPC() { |
| 407 | if e.MethodExpr.IsStreaming() { |
| 408 | if e.SSE != nil { |
| 409 | hasSSE = true |
| 410 | } else { |
| 411 | hasWebSocket = true |
| 412 | } |
| 413 | } else { |
| 414 | hasRegular = true |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | // WebSocket cannot be mixed with any other transport |
| 420 | if hasWebSocket && (hasSSE || hasRegular) { |
| 421 | verr.Add(svc, "JSON-RPC service %q cannot mix WebSocket with other transports (SSE or regular HTTP). WebSocket requires a single persistent connection for all methods.", svc.Name()) |
| 422 | } |
| 423 | // HTTP and SSE can be mixed - they both use POST requests and can share the same endpoint |
| 424 | } |
| 425 | |
| 426 | // validateJSONRPCRoutes validates that JSON-RPC routes use the correct HTTP method. |
| 427 | func (svc *HTTPServiceExpr) validateJSONRPCRoutes(verr *eval.ValidationErrors) { |
no test coverage detected