Start the server (from your module root):
go run ./cmd/server
Use curl to send a JSON‑RPC request:
curl -s -X POST localhost:8080/rpc -H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"1","method":"add","params":{"a":2,"b":40}}'
When your method uses mixed results (non‑streaming + streaming), request SSE:
curl -N -X POST localhost:8080/rpc -H 'Accept: text/event-stream' \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"1","method":"add","params":{"a":2,"b":40}}'
For bidirectional streaming, expose the JSON‑RPC endpoint with GET
to allow WebSocket upgrade and use StreamingPayload
/StreamingResult
in your design. Clients maintain a single connection per service and exchange JSON‑RPC messages over it.
id
in the request body; the server will not send a response.For details, see the JSON‑RPC concepts pages: