Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILocalComponent component, ILogger <Startup> logger)
        {
            //app.Run(async (context) =>
            //{
            //	_loggerFactory.CreateLogger("Run").LogInformation("Run logowanie");
            //	logger.LogInformation(10, "testowanie 11111");
            //	await context.Response.WriteAsync("Testowanie");
            //});

            //      app.UseMiddleware<TestMiddelware>();
            //      app.UseRouter(builder =>
            //      {
            //       builder.MapRoute(string.Empty, context =>
            //       {
            //		var routeValues = new RouteValueDictionary
            //		{
            //			{ "number", 456 }
            //		};

            //		var vpc = new VirtualPathContext(context, null, routeValues, "bar/{number:int}");
            //        var route = builder.Routes.Single(r => r.ToString().Equals(vpc.RouteName));
            //        var baseUrl = route.GetVirtualPath(vpc).VirtualPath;
            //        return context.Response.WriteAsync(baseUrl);
            //       });


            //       builder.MapGet("foo/{name}/{surname?}/{*aaa}", (request, response, routeData) =>
            //        response.WriteAsync($"Welcome to second route " +
            //                            $"{string.Join(";", routeData.Values.Select(data => $"{data.Key} => {data.Value}"))}"));

            //       builder.MapPost("bar/{number:int}", (context) =>
            //        context.Response.WriteAsync(
            //	        $"Welcome to post action" +
            //			$"{string.Join(";", context.GetRouteData().Values.Select(data => $"{data.Key} => {data.Value}"))}"));
            //});

            logger.LogError("test");

            app.UseStatusCodePages();
            app.UseDeveloperExceptionPage();
            app.UseAuthentication();
            app.UseMvc();
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILocalComponent component)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Use(async(context, next) =>
            {
                if (context.Request.Path == "/foo")
                {
                    await context.Response.WriteAsync($"Welcome to Foo");
                }
                else
                {
                    await next();
                }
            });

            app.Use(async(context, next) =>
            {
                if (context.Request.Path == "/bar")
                {
                    await context.Response.WriteAsync($"Welcome to Bar");
                }
                else
                {
                    await next();
                }
            });

            app.Run(async(context) =>
            {
                await context.Response.WriteAsync($"Test envinronment");
            });
        }