fix drpc method passing
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
6f4e54a876
commit
de02d636ad
@ -18,13 +18,16 @@ type drpcRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// service Struct.Method /service.Struct/Method
|
// service Struct.Method /service.Struct/Method
|
||||||
func methodToDRPC(_ string, method string) string {
|
func methodToDRPC(service string, method string) string {
|
||||||
// no method or already drpc method
|
// no method or already drpc method
|
||||||
if len(method) == 0 || method[0] == '/' {
|
if len(method) == 0 || method[0] == '/' {
|
||||||
return method
|
return method
|
||||||
}
|
}
|
||||||
|
|
||||||
idx := strings.LastIndex(method, ".")
|
idx := strings.LastIndex(method, ".")
|
||||||
|
if len(method) < 3 || idx < 2 {
|
||||||
|
return fmt.Sprintf("/%s.%s", strings.Title(service), method)
|
||||||
|
}
|
||||||
drpcService := method[:idx]
|
drpcService := method[:idx]
|
||||||
drpcMethod := method[idx+1:]
|
drpcMethod := method[idx+1:]
|
||||||
return fmt.Sprintf("/%s/%s", drpcService, drpcMethod)
|
return fmt.Sprintf("/%s/%s", drpcService, drpcMethod)
|
||||||
|
@ -12,7 +12,7 @@ func TestMethodToDRPC(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"helloworld",
|
"helloworld",
|
||||||
"Greeter.SayHello",
|
"Greeter/SayHello",
|
||||||
"/Helloworld.Greeter/SayHello",
|
"/Helloworld.Greeter/SayHello",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user