Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            services.AddHealthChecks()
            .AddCheck <FtpHealthCheck>("Ftp")
            .AddCheck <MongoHealthCheck>("Mongo");

            services.AddCors(options =>
            {
                options.AddPolicy(_corsSpecifications,
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });

            services.AddControllers();

            services.AddSwaggerGen(c =>
            {
                c.DocumentFilter <BasePathFilter>();

                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version     = "V1",
                    Title       = "Strategic project management API",
                    Description = "GEP (Strategic Project Management) is an API to expose the projects carried out by the city hall of Bom Destino."
                });

                c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    Description = "JWT Authorization header using the Bearer scheme.",
                    Name        = "Authorization",
                    In          = ParameterLocation.Header,
                    Type        = SecuritySchemeType.ApiKey
                });

                c.AddSecurityRequirement(new OpenApiSecurityRequirement {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "Bearer"
                            }
                        },
                        new string[] { }
                    }
                });
            });

            ServicesBootStrap.RegisterServices(services, Configuration);

            // MediatR
            services.AddMediatR(typeof(Startup).Assembly);
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc()
            .AddFluentValidation(f => f.RegisterValidatorsFromAssemblyContaining <Startup>());

            services.AddMvc();

            services.AddCors(options =>
            {
                options.AddPolicy(_corsSpecifications,
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });
            services.AddControllers();

            services.AddSwaggerGen(c =>
            {
                c.DocumentFilter <BasePathFilter>();

                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version     = "V1",
                    Title       = "Citizen Service API",
                    Description = "SAC (Citizen Service) is an API for exposing property and rural taxes in the municipality of Bom Destino."
                });

                c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    Description = "JWT Authorization header using the Bearer scheme.",
                    Name        = "Authorization",
                    In          = ParameterLocation.Header,
                    Type        = SecuritySchemeType.ApiKey
                });

                c.AddSecurityRequirement(new OpenApiSecurityRequirement {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "Bearer"
                            }
                        },
                        new string[] { }
                    }
                });
            });

            ServicesBootStrap.RegisterServices(services, Configuration);

            // MediatR
            services.AddMediatR(typeof(Startup).Assembly);
        }
Exemplo n.º 3
0
 public void ConfigureServices(IServiceCollection services, IConfiguration config)
 {
     ServicesBootStrap.RegisterServices(services, config);
     services.AddScoped <ReadProjectJob>();
 }