Ejemplo n.º 1
0
        /// <summary>
        /// Registers Ocelot with a combination of default middlewares and optional middlewares in the configuration
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="pipelineConfiguration"></param>
        /// <returns></returns>
        public static async Task <IApplicationBuilder> UseOcelot(this IApplicationBuilder builder, OcelotPipelineConfiguration pipelineConfiguration)
        {
            var configuration = await CreateConfiguration(builder);

            CreateAdministrationArea(builder, configuration);

            if (UsingRafty(builder))
            {
                SetUpRafty(builder);
            }

            ConfigureDiagnosticListener(builder);

            var pipelineBuilder = new OcelotPipelineBuilder(builder.ApplicationServices);

            pipelineBuilder.BuildOcelotPipeline(pipelineConfiguration);

            var firstDelegate = pipelineBuilder.Build();

            //inject first delegate into first piece of asp.net middleware..maybe not like this
            //then because we are updating the http context in ocelot it comes out correct for
            //rest of asp.net..

            builder.Use(async(context, task) =>
            {
                var downstreamContext = new DownstreamContext(context);
                await firstDelegate.Invoke(downstreamContext);
            });

            return(builder);
        }
        private static IApplicationBuilder CreateOcelotPipeline(IApplicationBuilder builder, OcelotPipelineConfiguration pipelineConfiguration)
        {
            OcelotPipelineBuilder ocelotPipelineBuilder = new OcelotPipelineBuilder(builder.ApplicationServices);

            ocelotPipelineBuilder.BuildOcelotPipeline(pipelineConfiguration);
            OcelotRequestDelegate firstDelegate = ocelotPipelineBuilder.Build();

            builder.Properties["analysis.NextMiddlewareName"] = "TransitionToOcelotMiddleware";
            builder.Use(async delegate(HttpContext context, Func <Task> task)
            {
                DownstreamContext downstreamContext = new DownstreamContext(context);
                await firstDelegate(downstreamContext);
            });
            return(builder);
        }
        private static IApplicationBuilder CreateOcelotPipeline(IApplicationBuilder builder, OcelotPipelineConfiguration pipelineConfiguration)
        {
            var pipelineBuilder = new OcelotPipelineBuilder(builder.ApplicationServices);

            pipelineBuilder.BuildOcelotPipeline(pipelineConfiguration);
            var firstDelegate = pipelineBuilder.Build();

            builder.Properties["analysis.NextMiddlewareName"] = "TransitionToOcelotMiddleware";
            builder.Use(async(context, task) =>
            {
                var downstreamContext = new DownstreamContext(context);
                await firstDelegate.Invoke(downstreamContext);
            });
            return(builder);
        }
Ejemplo n.º 4
0
        public static async Task <IApplicationBuilder> UseOcelot(this IApplicationBuilder builder, OcelotPipelineConfiguration pipelineConfiguration)
        {
            var configuration = await CreateConfiguration(builder);

            CreateAdministrationArea(builder, configuration);

            if (UsingRafty(builder))
            {
                SetUpRafty(builder);
            }

            if (UsingEurekaServiceDiscoveryProvider(configuration))
            {
                builder.UseDiscoveryClient();
            }

            ConfigureDiagnosticListener(builder);

            var pipelineBuilder = new OcelotPipelineBuilder(builder.ApplicationServices);

            pipelineBuilder.BuildOcelotPipeline(pipelineConfiguration);

            var firstDelegate = pipelineBuilder.Build();

            /*
             * inject first delegate into first piece of asp.net middleware..maybe not like this
             * then because we are updating the http context in ocelot it comes out correct for
             * rest of asp.net..
             */

            builder.Properties["analysis.NextMiddlewareName"] = "TransitionToOcelotMiddleware";

            builder.Use(async(context, task) =>
            {
                var downstreamContext = new DownstreamContext(context);
                await firstDelegate.Invoke(downstreamContext);
            });

            return(builder);
        }
Ejemplo n.º 5
0
        private static IApplicationBuilder CreateOcelotPipeline(IApplicationBuilder builder, OcelotPipelineConfiguration pipelineConfiguration)
        {
            var pipelineBuilder = new OcelotPipelineBuilder(builder.ApplicationServices);

            pipelineBuilder.BuildOcelotPipeline(pipelineConfiguration);

            var firstDelegate = pipelineBuilder.Build();

            /*
             * inject first delegate into first piece of asp.net middleware..maybe not like this
             * then because we are updating the http context in ocelot it comes out correct for
             * rest of asp.net..
             */

            builder.Properties["analysis.NextMiddlewareName"] = "TransitionToOcelotMiddleware";

            builder.Use(async(context, task) =>
            {
                var downstreamContext = new DownstreamContext(context);
                await firstDelegate.Invoke(downstreamContext);
            });

            return(builder);
        }
Ejemplo n.º 6
0
 private void WhenIBuild()
 {
     _handlers = _builder.BuildOcelotPipeline(new OcelotPipelineConfiguration());
 }