Esempio n. 1
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        /// <param name="app">Application builder object</param>
        /// <param name="env">Web host environment data</param>
        /// <param name="serviceProvider">Service provider collection</param>
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                //endpoints.MapGrpcService<GreeterService>();
                endpoints.MapGrpcService <LaborTaxesGrpcService>();

                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync("Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
                });
            });

            // Create database objects
            IDbDocumentCollectionCreator creators = serviceProvider.GetService <IDbDocumentCollectionCreator>();

            creators.Create().Wait();

            // Seed data from seeders
            var dbDataSeeder = serviceProvider.GetService <IDbDataSeeder>();

            dbDataSeeder.Seed().Wait();
        }
Esempio n. 2
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        /// <param name="app">Application builder object</param>
        /// <param name="env">Web host environment data</param>
        /// <param name="serviceProvider">Service provider collection</param>
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();
            app.UseAuthorization();

            app.UseApplicationSwagger();
            app.UseApplicationHealthChecks();

            app.UseCors(c =>
            {
                c.AllowAnyHeader();
                c.AllowAnyMethod();
                c.AllowAnyOrigin();
            });

            app.UseStaticFiles();
            app.UseResponseCaching();

            app.UseMiddleware <RequestResponseLogging <Startup> >();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            // Create database objects
            IDbDocumentCollectionCreator creators = serviceProvider.GetService <IDbDocumentCollectionCreator>();

            creators.Create().Wait();

            // Seed data from seeders
            var dbDataSeeder = serviceProvider.GetService <IDbDataSeeder>();

            dbDataSeeder.Seed().Wait();
        }