Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="routers"></param>
        /// <param name="rpcConfig"></param>
        public static void Initialize(IRouteBuilder routers, RpcConfig rpcConfig)
        {
            RpcManager.Initialize(rpcConfig);

            if (rpcConfig?.Service?.Paths != null)
            {
                foreach (var path in rpcConfig.Service.Paths)
                {
                    routers.MapRoute(path, context => RpcManager.ProcessAsync(new AspNetCoreServerContext(context)));
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// initialize with RpcConfigBuilder
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static void Initialize(Action <RpcConfigBuilder> builder)
        {
            lock (InitLocker)
            {
                if (_initialized)
                {
                    return;
                }

                RpcManager.Initialize(builder);

                _initialized = true;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="app"></param>
        /// <param name="rpcConfig"></param>
        public static void Initialize(IApplicationBuilder app, RpcConfig rpcConfig)
        {
            RpcManager.Initialize(rpcConfig);

            if (rpcConfig?.Service?.Paths == null)
            {
                return;
            }
            if (app == null)
            {
                return;
            }

            var routers = new RouteBuilder(app);

            foreach (var path in rpcConfig.Service.Paths)
            {
                routers.MapRoute(path + "{*RpcLiteServicePath}", context => RpcManager.ProcessAsync(new AspNetCoreServerContext(context)));
            }
            var routes1 = routers.Build();

            app.UseRouter(routes1);
        }
Exemplo n.º 4
0
 /// <summary>
 /// initialize with RpcConfig
 /// </summary>
 /// <param name="config"></param>
 public static void Initialize(RpcConfig config)
 {
     RpcManager.Initialize(config);
 }