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

Method validateJSONRPCRoutes

expr/http_service.go:427–445  ·  view source on GitHub ↗

validateJSONRPCRoutes validates that JSON-RPC routes use the correct HTTP method.

(verr *eval.ValidationErrors)

Source from the content-addressed store, hash-verified

425
426// validateJSONRPCRoutes validates that JSON-RPC routes use the correct HTTP method.
427func (svc *HTTPServiceExpr) validateJSONRPCRoutes(verr *eval.ValidationErrors) {
428 for _, e := range svc.HTTPEndpoints {
429 if e.IsJSONRPC() {
430 for _, r := range e.Routes {
431 // WebSocket requires GET
432 if e.MethodExpr.IsStreaming() && e.SSE == nil {
433 if r.Method != "GET" {
434 verr.Add(r, "JSON-RPC WebSocket endpoint must use GET method, got %q", r.Method)
435 }
436 } else {
437 // Regular JSON-RPC and SSE require POST
438 if r.Method != "POST" {
439 verr.Add(r, "JSON-RPC endpoint must use POST method, got %q", r.Method)
440 }
441 }
442 }
443 }
444 }
445}

Callers 1

validateTransportsMethod · 0.95

Calls 3

IsJSONRPCMethod · 0.80
AddMethod · 0.80
IsStreamingMethod · 0.45

Tested by

no test coverage detected