Пример #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)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async(context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });

            BusBootStrapper.ConfigureEventBus(app);
            BootStrapper.RegisterTranslators(app);
        }
Пример #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.Configure <BluePrint>(Configuration.GetSection("Settings"));
            services.Configure <BluePrint>(Configuration.GetSection("Features"));
            services.AddSingleton <IConfiguration>(Configuration);
            services.AddHealthChecks();



            services.AddSingleton <IConfiguration>(Configuration);

            services.AddOptions();
            BusBootStrapper.RegisterEventBus(services, Configuration);
            BootStrapper.RegisterComponents(services, Configuration);

            var container = new ContainerBuilder();

            container.Populate(services);
            return(new AutofacServiceProvider(container.Build()));
        }
Пример #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();

            var pathBase = Configuration["PATH_BASE"];

            if (!string.IsNullOrEmpty(pathBase))
            {
                app.UsePathBase(pathBase);
            }


#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
            app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously

            app.UseStaticFiles();
            app.UseCors("CorsPolicy");

            ConfigureAuth(app);

            app.UseMvcWithDefaultRoute();

            app.UseSwagger()
            .UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "manager.web.api V1");
                c.OAuthClientId("managerswaggerui");
                c.OAuthAppName("Manager Swagger UI");
            });

            BusBootStrapper.ConfigureEventBus(app);
        }
Пример #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(HttpGlobalExceptionFilter));
                options.Filters.Add(typeof(ValidateModelStateFilter));
            }
                            ).AddControllersAsServices().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.Configure <BluePrint>(Configuration.GetSection("Settings"));
            services.Configure <BluePrint>(Configuration.GetSection("Features"));
            services.AddSingleton <IConfiguration>(Configuration);
            ConfigureAuthService(services);

            services.AddHealthChecks();


            BusBootStrapper.RegisterEventBus(services, Configuration);
            BootStrapper.RegisterComponents(services, Configuration);

            services.AddSwaggerGen(options =>
            {
                options.DescribeAllEnumsAsStrings();
                options.SwaggerDoc("v1", new Info
                {
                    Title          = "Manager HTTP API",
                    Version        = "v1",
                    Description    = "The Manager Service HTTP API",
                    TermsOfService = "Terms Of Service"
                });

                options.AddSecurityDefinition("oauth2", new OAuth2Scheme
                {
                    Type             = "oauth2",
                    Flow             = "implicit",
                    AuthorizationUrl = $"{Configuration.GetValue<string>("IdentityUrlExternal")}/connect/authorize",
                    TokenUrl         = $"{Configuration.GetValue<string>("IdentityUrlExternal")}/connect/token",
                    Scopes           = new Dictionary <string, string>()
                    {
                        { "manager", "Manager API" }
                    }
                });

                options.OperationFilter <AuthorizeCheckOperationFilter>();
            });

            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder.AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  .AllowCredentials());
            });
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddTransient <IJobRepository, JobRepository>();
            services.AddTransient <IIdentityService, IdentityService>();

            services.AddOptions();

            var container = new ContainerBuilder();

            container.Populate(services);

            return(new  AutofacServiceProvider(container.Build()));
        }
 public void BootStrapTheApplication()
 {
     BusBootStrapper.BootStrap(WebApiApplication.PersonKarnel);
 }