Skip to content

Commit

Permalink
add documentation for default id
Browse files Browse the repository at this point in the history
  • Loading branch information
Sapexoid committed Apr 8, 2022
1 parent 1ca496a commit 14f33ce
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,3 +496,20 @@ func main() {
// unknown fields are now allowed in the response
}
```

### Change default RPCRequestID

By default, the client will set the id of an RPCRequest to 0.
This can be changed by setting the RPCClientOpts.DefaultRPCRequestID to a custom value:

```go
func main() {
rpcClient := jsonrpc.NewClientWithOpts("http://my-rpc-service:8080/rpc", &jsonrpc.RPCClientOpts{
DefaultRPCRequestID: 1,
})

// requests now have default id 1
}
```

You may also use NewRequestWithID() to set a custom id when creating a raw request.

0 comments on commit 14f33ce

Please sign in to comment.