Beispiel #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,
                       IApplicationLifetime applicationLifetime,
                       IMongoDbInitializer mongoInitializer)
 {
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
     }
     else
     {
         app.UseHsts();
     }
     mongoInitializer.InitializeAsync();
     //app.UseHttpsRedirection();
     app.UseRabbitMq()
     .SubscribeCommand <CreateProduct>();
     app.UseMvc();
     applicationLifetime.ApplicationStopped
     .Register(() => Container.Dispose());
 }
Beispiel #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, IMongoDbInitializer mongoDbInitializer)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            mongoDbInitializer.Initialize();
            app.UseMvc();
            //TODO: Figure a better way of doing this
            app.UseRabbitMq()
            .SubscribeCommand <CreateRide>();
            // app.UseRabbitMq()
            //    .SubscribeCommand<CreateRide>(onError: (cmd, e) => { throw new Exception("could not execute command" + cmd.CarType); });

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
            });
        }
Beispiel #3
0
        public void Configure(
            IApplicationBuilder app,
            IWebHostEnvironment env,
            IMongoDbInitializer mongoDbInitializer)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseCors(builder =>
                        builder.SetIsOriginAllowed(host => true).AllowAnyHeader().AllowAnyMethod().AllowCredentials());

            app.UseHttpsRedirection();

            app.UseOpenApi();
            app.UseSwaggerUi3();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller}/{action=Index}/{id?}");
                endpoints.MapHub <BoardHub>("api/hubs/board");
            });

            mongoDbInitializer.InitializeAsync();
        }