Example #1
0
        public async Task InvokeAsync(HttpContext context)
        {
            var path   = context.Request.Path;
            var method = context.Request.Method.ToEnum <HttpMethod>();


            var serviceEntry = _serviceEntryLocator.GetServiceEntryByApi(path, method);

            if (serviceEntry != null)
            {
                await EngineContext.Current
                .ResolveNamed <IMessageReceivedHandler>(serviceEntry.ServiceDescriptor.ServiceProtocol.ToString())
                .Handle(context, serviceEntry);
            }
            else
            {
                await _next(context);
            }
        }
Example #2
0
        public async Task InvokeAsync(HttpContext context)
        {
            var path   = context.Request.Path;
            var method = context.Request.Method.ToEnum <HttpMethod>();


            var serviceEntry = _serviceEntryLocator.GetServiceEntryByApi(path, method);

            if (serviceEntry != null)
            {
                if (serviceEntry.GovernanceOptions.ProhibitExtranet)
                {
                    throw new FuseProtectionException($"Id为{serviceEntry.Id}的服务条目不允许外网访问");
                }
                await EngineContext.Current
                .ResolveNamed <IMessageReceivedHandler>(serviceEntry.ServiceDescriptor.ServiceProtocol.ToString())
                .Handle(context, serviceEntry);
            }
            else
            {
                await _next(context);
            }
        }