validateJSONRPCRoutes validates that JSON-RPC routes use the correct HTTP method.
(verr *eval.ValidationErrors)
| 425 | |
| 426 | // validateJSONRPCRoutes validates that JSON-RPC routes use the correct HTTP method. |
| 427 | func (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 | } |
no test coverage detected