proposal: support custom method names in net/rpc
tdterry opened this issue · 2 comments
I'm converting a legacy system that uses json-rpc into Go, and I have some restrictions on the method names that don't work with Go's RPC layer. The legacy method names are all lowercase and do not have a namespace structure "method_name". Go's RPC layer wants to use "Class.Method" as the method name. It would be very useful to be able to either a) provide a mapping of method names when registering a handler or b) register individual methods with a custom name.
Something like this, as taken from the net/rpc package example:
arith := new(Arith)
rpc.RegisterWithNames(arith, map[string]string{
"mul": "Arith.Multiply",
"div": "Arith.Divide",
})
// or
rpc.RegisterMethod("mul", Arith.Multiply)
rpc.RegisterMethod("div", Arith.Divide)
I actually keep a small fork of net/rpc
for this very reason, and it's not a legacy system, it's something designed in the last couple of years. Some people simply have different tasted when designing APIs :-P