Ejemplo n.º 1
0
Archivo: Startup.cs Proyecto: gpauls/MS
        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            MSMvcContext.RegisterControllers(app);

            MSMvcContext.Register(new Registrar(),
                                  new MS.Infrastructure.Messaging.Registrar(),
                                  new MS.Infrastructure.Handling.Registrar(),
                                  new MS.Employees.Registrar(),
                                  new MS.Employees.Worker.Registrar() // TODO dont start this one with web app, but with command line instead
                                  );

            MSMvcContext.Verify();

            app.Use(async(context, next) =>
            {
                using (MSMvcContext.BeginExecutionContextScope())
                {
                    await next();
                }
            });

            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();

            // Configure the HTTP request pipeline.

            // Add the following to the request pipeline only in development environment.
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseErrorPage(ErrorPageOptions.ShowAll);
            }
            else
            {
                // Add Error handling middleware which catches all application specific errors and
                // send the request to the following path or controller action.
                app.UseErrorHandler("/Home/Error");
            }

            // Add static files to the request pipeline.
            app.UseStaticFiles();

            // Add MVC to the request pipeline.
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");

                // Uncomment the following line to add a route for porting Web API 2 controllers.
                // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
            });

            Boot.AppStart();
        }