Skip to content

Commit 14f33ce

Browse files
committed
add documentation for default id
1 parent 1ca496a commit 14f33ce

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,3 +496,20 @@ func main() {
496496
// unknown fields are now allowed in the response
497497
}
498498
```
499+
500+
### Change default RPCRequestID
501+
502+
By default, the client will set the id of an RPCRequest to 0.
503+
This can be changed by setting the RPCClientOpts.DefaultRPCRequestID to a custom value:
504+
505+
```go
506+
func main() {
507+
rpcClient := jsonrpc.NewClientWithOpts("http://my-rpc-service:8080/rpc", &jsonrpc.RPCClientOpts{
508+
DefaultRPCRequestID: 1,
509+
})
510+
511+
// requests now have default id 1
512+
}
513+
```
514+
515+
You may also use NewRequestWithID() to set a custom id when creating a raw request.

0 commit comments

Comments
 (0)