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)); }; }
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)); }); }