Beispiel #1
0
        public HttpServiceOnceApiConvert(List <ContractInfo> contracts,
                                         HttpContext context,
                                         string?rootPath,
                                         bool ignoreWhenNotMatched,
                                         IHubContext <CallbackHub, ICallback> hub,
                                         HttpObjProcessorManager httpObjProcessorManager,
                                         IServiceProvider serviceProvider)
        {
            var logger = ((ILoggerFactory)serviceProvider.GetService(typeof(ILoggerFactory))).CreateLogger("NetRpc");

            _contracts               = contracts;
            _context                 = context;
            _connection              = new HttpConnection(context, hub, logger);
            _rootPath                = rootPath;
            _ignoreWhenNotMatched    = ignoreWhenNotMatched;
            _httpObjProcessorManager = httpObjProcessorManager;
            CallbackHub.Canceled    += CallbackHubCanceled;
        }
Beispiel #2
0
        public async Task Invoke(HttpContext httpContext, IOptions <ContractOptions> contractOptions, IHubContext <CallbackHub, ICallback> hub,
                                 IOptions <HttpServiceOptions> httpOptions, RequestHandler requestHandler, HttpObjProcessorManager httpObjProcessorManager,
                                 IServiceProvider serviceProvider)
        {
            //if grpc channel message go to next.
            if (httpContext.Request.Path.Value.EndsWith("DuplexStreamingServerMethod"))
            {
                await _next(httpContext);

                return;
            }

            bool notMatched;

            await using (var convert = new HttpServiceOnceApiConvert(contractOptions.Value.Contracts, httpContext, httpOptions.Value.ApiRootPath,
                                                                     httpOptions.Value.IgnoreWhenNotMatched, hub, httpObjProcessorManager, serviceProvider))
            {
                await requestHandler.HandleAsync(convert, ChannelType.Http);

                notMatched = convert.NotMatched;
            }

            if (httpOptions.Value.IgnoreWhenNotMatched && notMatched)
            {
                await _next(httpContext);
            }
        }