@@ -65,9 +65,13 @@ public int onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int
6565 int processed = data .readableBytes () + padding ;
6666 if (endOfStream ) {
6767 Invocation invocation = buildInvocation (request .getHeaders (), request .getData ());
68+ final String path = request .getHeaders ().path ().toString ();
69+ String [] parts = path .split ("/" );
70+ // todo parts illegal service not found
71+ String serviceName = parts [1 ];
6872 // TODO add version/group support
6973 //TODO add method not found / service not found err
70- Result result = serviceContainer .resolve ("io.grpc.examples.helloworld.IGreeter" ).invoke (invocation );
74+ Result result = serviceContainer .resolve (serviceName ).invoke (invocation );
7175 CompletionStage <Object > future = result .thenApply (Function .identity ());
7276
7377 future .whenComplete ((appResult , t ) -> {
@@ -103,9 +107,11 @@ private Invocation buildInvocation(Http2Headers http2Headers, ByteBuf data) {
103107 RpcInvocation inv = new RpcInvocation ();
104108 final String path = http2Headers .path ().toString ();
105109 String [] parts = path .split ("/" );
106- // todo
107- String serviceName = "io.grpc.examples.helloworld.IGreeter" ;
108- String methodName = "sayHello" ;
110+ // todo parts illegal service not found
111+ String serviceName = parts [1 ];
112+ String originalMethodName = parts [2 ];
113+ String methodName = originalMethodName .substring (0 ,1 ).toLowerCase ().concat (originalMethodName .substring (1 ));
114+
109115 ServiceRepository repo = ApplicationModel .getServiceRepository ();
110116 MethodDescriptor methodDescriptor = repo .lookupMethod (serviceName , methodName );
111117 Object obj = Marshaller .marshaller .unmarshaller (methodDescriptor .getParameterClasses ()[0 ], data );
0 commit comments