예제 #1
0
 private void AddEndpoint <TRequest, TResponse>(IRpcServiceResolver rpcServiceResolver)
     where TRequest : class, new()
     where TResponse : class, new()
 {
     Post[typeof(TRequest).Name, true] = async(ctx, ct) =>
     {
         IRpcService <TRequest, TResponse> rpcService = rpcServiceResolver.GetRpcService <TRequest, TResponse>();
         var request = this.Bind <TRequest>();
         return(await rpcService.Execute(request, ct));
     };
 }
예제 #2
0
 private void AddEndpoint <TRequest, TResponse>(IRpcServiceResolver rpcServiceResolver)
     where TRequest : class, new()
     where TResponse : class, new()
 {
     Post("/" + typeof(TRequest).GetCustomAttributes <RpcMethodAttribute>().First().MethodName,
          async(ctx, ct) =>
     {
         var rpcService  = rpcServiceResolver.GetRpcService <TRequest, TResponse>();
         var rpcRequest  = Bind <TRequest>();
         var rpcResponse = await rpcService.Execute(rpcRequest, ct);
         return(this.Response.AsJson(rpcResponse));
     });
 }