Esempio n. 1
0
        public AspNetCoreCommunicationListener(AspNetCoreCommunicationContext context, StatefulService service)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            _context  = context;
            _service  = service;
            _registry = _context.WebHost.Services.GetService <ServiceFabricServiceRegistry>();
        }
Esempio n. 2
0
        public async Task Invoke(HttpContext context, ServiceFabricServiceRegistry registry, ServiceFabricServiceScope scope)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (scope == null)
            {
                throw new ArgumentNullException(nameof(scope));
            }

            PathString servicePathBase;
            PathString remainingPath;
            object     service;

            if (!registry.TryGet(context.Request.Path, out servicePathBase, out remainingPath, out service))
            {
                context.Response.StatusCode = 503;
                return;
            }

            StringValues pathBase;

            if (context.Request.Headers.TryGetValue("X-ServiceFabric-PathBase", out pathBase))
            {
                servicePathBase = pathBase.FirstOrDefault();
            }

            context.Request.PathBase = servicePathBase + context.Request.PathBase;
            context.Request.Path     = remainingPath;
            scope.Service            = service;

            await _next.Invoke(context);
        }
        public async Task Invoke(HttpContext context, ServiceFabricServiceRegistry registry, ServiceFabricServiceScope scope)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (scope == null)
            {
                throw new ArgumentNullException(nameof(scope));
            }

            PathString servicePathBase;
            PathString remainingPath;
            object service;

            if (!registry.TryGet(context.Request.Path, out servicePathBase, out remainingPath, out service))
            {
                context.Response.StatusCode = 503;
                return;
            }

            StringValues pathBase;
            if (context.Request.Headers.TryGetValue("X-ServiceFabric-PathBase", out pathBase))
            {
                servicePathBase = pathBase.FirstOrDefault();
            }

            context.Request.PathBase = servicePathBase + context.Request.PathBase;
            context.Request.Path = remainingPath;
            scope.Service = service;

            await _next.Invoke(context);
        }