Exemple #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            AddAuthentication(services);

            services.Configure <KestrelServerOptions>(options =>
            {
                options.AllowSynchronousIO = true;
            });

            services.AdicionarRedis();

            services.AddResponseCompression(options =>
            {
                options.Providers.Add <GzipCompressionProvider>();
                options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[] { "application/json" });
            });
            RegistrarMapeamentos.Registrar();
            RegistrarMvc.Registrar(services, Configuration);

            services.AddInfrastructure();
            services.AddApplication();
            services.AdicionarValidadoresFluentValidation();
            services.AddCors(options => options.AddDefaultPolicy(
                                 builder =>
            {
                builder.WithOrigins("*");
            })
                             );
            services
            .AddControllers()
            .AddNewtonsoftJson();

            // Register the Swagger generator, defining 1 or more Swagger documents
            registrarSwagger(services);
        }
Exemple #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <KestrelServerOptions>(options =>
            {
                options.AllowSynchronousIO = true;
            });

            services.AddResponseCompression(options =>
            {
                options.Providers.Add <GzipCompressionProvider>();
                options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[] { "application/json" });
            });

            var variaveisGlobais = new VariaveisGlobaisOptions();

            Configuration.GetSection(nameof(VariaveisGlobaisOptions)).Bind(variaveisGlobais, c => c.BindNonPublicProperties = true);

            var servicoProdam = new ServicoProdamOptions();

            Configuration.GetSection(nameof(ServicoProdamOptions)).Bind(servicoProdam, c => c.BindNonPublicProperties = true);

            var jwtVariaveis = new SgpJwtOptions();

            Configuration.GetSection(nameof(SgpJwtOptions)).Bind(jwtVariaveis, c => c.BindNonPublicProperties = true);

            services.AddSingleton(variaveisGlobais);
            services.AddSingleton(servicoProdam);
            services.AddSingleton(jwtVariaveis);

            AddAuthentication(services, variaveisGlobais);

            services.AddApplicationInsightsTelemetry(Configuration);

            RegistrarMapeamentos.Registrar();
            RegistrarMvc.Registrar(services, variaveisGlobais);
            RegistrarClientesHttp.Registrar(services, servicoProdam, variaveisGlobais);
            ConfiguraVariaveisAmbiente(services);

            services.AddInfrastructure(variaveisGlobais);
            services.AddApplication();
            services.AdicionarValidadoresFluentValidation();
            services.AddCors(options => options.AddDefaultPolicy(
                                 builder =>
            {
                builder.WithOrigins("*");
            })
                             );
            services
            .AddControllers()
            .AddNewtonsoftJson();

            // Register the Swagger generator, defining 1 or more Swagger documents
            RegistrarSwagger(services);
            services.AddApplicationInsightsTelemetry();
        }