MCPcopy Create free account
hub / github.com/goadesign/goa / validateJSONRPCTransportConsistency

Method validateJSONRPCTransportConsistency

expr/http_service.go:402–424  ·  view source on GitHub ↗

validateJSONRPCTransportConsistency validates JSON-RPC transport combinations. WebSocket cannot be mixed with other transports, but HTTP and SSE can coexist.

(verr *eval.ValidationErrors)

Source from the content-addressed store, hash-verified

400// validateJSONRPCTransportConsistency validates JSON-RPC transport combinations.
401// WebSocket cannot be mixed with other transports, but HTTP and SSE can coexist.
402func (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.
427func (svc *HTTPServiceExpr) validateJSONRPCRoutes(verr *eval.ValidationErrors) {

Callers 1

validateTransportsMethod · 0.95

Calls 4

NameMethod · 0.95
IsJSONRPCMethod · 0.80
AddMethod · 0.80
IsStreamingMethod · 0.45

Tested by

no test coverage detected