// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            //app.UseMvcWithDefaultRoute();
            app.UseStaticFiles();

            //Custom Middleware
            app.UseMyCustomMiddleware();

            //Middleware
            app.Use(async(context, next) =>
            {
                await context.Response.WriteAsync(_configuration["MyKey"]);
                await context.Response.WriteAsync("\n Hello World main!(before)\n");
                await next();
                await context.Response.WriteAsync("Hello World main! (after)\n");
            });

            //nested maps
            app.Map("/map1",
                    FirstMiddleware => FirstMiddleware.Map("/map1a",
                                                           SecondMiddleware => SecondMiddleware.Run(async(context) =>
                                                                                                    await context.Response.WriteAsync("Hello from Nested Middleware\n"))));

            //Map Delegate
            app.Map("/map", HandleMap);

            //MapWhen for conditional non-rejoining branching
            app.MapWhen(context => context.Request.Query.ContainsKey("branch"), HandleBranch);

            //UseWhen for conditional rejoining branching
            app.UseWhen(
                context => context.Request.Path.StartsWithSegments(new PathString("/UseWhen")),
                a => a.Use(async(context, next) =>
            {
                await context.Response.WriteAsync("Hello World From UseWhen (before)!\n");
                await next();
                await context.Response.WriteAsync("Hello World From UseWhen (after)!\n");
            }));

            //Terminal middleware (Run)
            app.Run(TerminalMiddleware);
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseWelcomePage();

            app.UseStaticFiles();

            app.Use(async(context, next) =>
            {
                await context.Response.WriteAsync(_configuration["MyKey"]);
                await context.Response.WriteAsync("\nHello from Use Main\n");
                await context.Response.WriteAsync("\nFrom A (before)\n");
                await next();
                await context.Response.WriteAsync("\nFrom A (after)\n");
            });

            app.UseWhen(
                context => context.Request.Path.StartsWithSegments(new PathString("/UseWhen")),
                a => a.Use(async(context, next) =>
            {
                await context.Response.WriteAsync("\nFrom B (before)\n");
                await next();
                await context.Response.WriteAsync("\nFrom B (after)\n");
            }));

            app.Map("/map", MyMiddleware);

            app.Map("/map1",
                    FirstMiddleware => FirstMiddleware.Map("/map1a",
                                                           SecondMiddleware => SecondMiddleware.Run(async(context) =>
                                                                                                    await context.Response.WriteAsync("Hello from Nested Middleware\n"))));

            app.Run(async context => await context.Response.WriteAsync("From Run Main"));
        }