File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,53 @@ if err := client.Call(); err != nil {
244244}
245245```
246246
247+ ## Options
248+
249+
250+ ### Using ` WithNamespaceSeparator `
251+ ``` go
252+ func main () {
253+ // create a new server instance with a custom namespace separator
254+ rpcServer := jsonrpc.NewServer (jsonrpc.WithNamespaceSeparator (" _" ))
255+
256+ // create a handler instance and register it
257+ serverHandler := &SimpleServerHandler{}
258+ rpcServer.Register (" SimpleServerHandler" , serverHandler)
259+
260+ // serve the api
261+ testServ := httptest.NewServer (rpcServer)
262+ defer testServ.Close ()
263+
264+ fmt.Println (" URL: " , " ws://" +testServ.Listener .Addr ().String ())
265+
266+ // rpc method becomes SimpleServerHandler_AddGet
267+
268+ [..do other app stuff / wait..]
269+ }
270+ ```
271+
272+ ### Using ` WithMethodTransformer `
273+ ``` go
274+ func main () {
275+ // create a new server instance with a custom method transformer
276+ rpcServer := jsonrpc.NewServer (jsonrpc.WithMethodTransformer (strcase.ToSnake ))
277+
278+ // create a handler instance and register it
279+ serverHandler := &SimpleServerHandler{}
280+ rpcServer.Register (" SimpleServerHandler" , serverHandler)
281+
282+ // serve the api
283+ testServ := httptest.NewServer (rpcServer)
284+ defer testServ.Close ()
285+
286+ fmt.Println (" URL: " , " ws://" +testServ.Listener .Addr ().String ())
287+
288+ // rpc method becomes SimpleServerHandler.add_get
289+
290+ [..do other app stuff / wait..]
291+ }
292+ ```
293+
247294## Contribute
248295
249296PRs are welcome!
You can’t perform that action at this time.
0 commit comments