gorilla/rpc

[feature] Add support for 'Service/Method' to support LSP

tristan957 opened this issue · 2 comments

A clear and concise description of what the problem is - e.g. "I'm always frustrated when [...]"

LSP has methods like textDocument/XXX. Gorilla RPC currently only supports textDocument.XXX. You can't implement a language server using Go and this package

What would the feature look like? How would it work? How would it change the API?

Some way to register a func for translating the service and method name to various formats or maybe registering a format string of some sort.

rpc.NewServerWithMethodFormatter(func(service string, method string) string {
  return fmt.Sprintf("%s/%s", strings.Lower(service), strings.Lower(method)
})

It will be great to extend this enhancement to support the PAWS protocol method format spectrum.paws.methodName

I currently get the following errors:

"jsonrpc": "2.0",
"error": {
        "code": -32000,
        "message": "rpc: service/method request ill-formed: \"spectrum.paws.init\"",
        "data": null
    },

spectrum.paws should be allowed as a service name as shown below:

s := rpc.NewServer()
s.RegisterCodec(json2.NewCodec(), "application/json")
s.RegisterService(new(SpectrumPaws), "spectrum.paws")