// This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureContainer(ServiceRegistry services)
        {
            services.AddDefaultCorrelationId();
            services.AddHttpContextAccessor();
            services.AddMvc();
            services.AddVersionedApiExplorer(options => options.GroupNameFormat = "'v'VVV");
            services.AddApiVersioning(o =>
            {
                o.ReportApiVersions = true;
                o.DefaultApiVersion = new ApiVersion(1, 0);
                o.AssumeDefaultVersionWhenUnspecified = true;
            });
            services.AddOptions();
            services.AddHttpClient(string.Empty)
            .AddCorrelationIdForwarding();

            services.AddSwagger();
            services.AddHealthChecks().AddCheck <ReadinessCheck>("PROJECT_NAME readiness", tags: new[] { "readiness" });
            services.AddCustomizedLogging();
            services.AddDependencyInjection(Configuration);

            services.AddHealthChecks();
            services.AddControllers()
            .AddJsonOptions(options =>
                            options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));
        }
Beispiel #2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureContainer(ServiceRegistry services)
 {
     services.AddCorrelationId();
     services.AddHttpContextAccessor();
     services.AddMvc();
     services.AddVersionedApiExplorer(options => options.GroupNameFormat = "'v'VVV");
     services.AddApiVersioning(o =>
     {
         o.ReportApiVersions = true;
         o.DefaultApiVersion = new ApiVersion(1, 0);
         o.AssumeDefaultVersionWhenUnspecified = true;
     });
     services.AddOptions();
     services.AddHttpClient();
     services.AddSwagger(Configuration);
     services.AddDependencyInjection(Configuration);
     services.AddControllers();
     services.AddHealthChecks();
     services.AddSwaggerGen(c =>
     {
         // This coupled with the properties in the csproj allow the swagger page to show additional comments for methods
         var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
         var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
         c.IncludeXmlComments(xmlPath);
     });
 }
Beispiel #3
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 void ConfigureContainer(ServiceRegistry services)
        {
            services.AddOptions();
            services.Configure <PersistenceConfiguration>(_config.GetSection(nameof(PersistenceConfiguration)));

            services.AddHealthChecks()
            .AddCheck <ContainerHealthCheck>("ioc")
            .AddCheck <DatabaseHealthCheck>("database");

            services.AddAuthenticationConfiguration(_config);

            services.AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
                options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
            });

            services.AddSignalR();

            services.AddSwaggerConfiguration();

            services.AddCorsConfiguration();
        }
        public void ConfigureContainer(ServiceRegistry services)
        {
            services.AddMvc();
            services.AddLogging();
            services.AddIdentityServer()
            .AddDeveloperSigningCredential()
            .AddInMemoryApiResources(Config.GetApiResources())
            .AddInMemoryClients(Config.GetClients());
            services.For <IMessageMaker>().Use(new MessageMaker("Hey there."));

            services.AddHealthChecks();

            services.AddHealthChecksUI();

            services.AddAuthentication()
            .AddIdentityServerAuthentication(options =>
            {
                options.Authority            = "auth";
                options.RequireHttpsMetadata = true;
            })


            .AddFacebook(facebookOptions =>
            {
                facebookOptions.AppId     = "something";
                facebookOptions.AppSecret = "else";
            });
        }
Beispiel #5
0
        public void ConfigureContainer(ServiceRegistry services)
        {
            services.AddSyrfDefaultServices(_configuration);
            services.AddSyrfDataServices(_configuration);
            services.AddSyrfFileService(_configuration);
            services.AddHealthChecks();
            services.AddControllers().AddControllersAsServices();
            services.ConfigureSyrfMassTransit(_configuration, null, (cfg, provider) =>
            {
                cfg.UseCircuitBreaker(cb =>
                {
                    cb.TrackingPeriod  = TimeSpan.FromMinutes(1);
                    cb.TripThreshold   = 15;
                    cb.ActiveThreshold = 10;
                    cb.ResetInterval   = TimeSpan.FromMinutes(5);
                });
                cfg.UseRateLimit(50, TimeSpan.FromSeconds(10));
            });
            services.Configure <HealthCheckPublisherOptions>(options =>
            {
                options.Delay     = TimeSpan.FromSeconds(2);
                options.Predicate = check => check.Tags.Contains("ready");
            });

            services.IncludeRegistry <SyrfRegistry>();
            services.IncludeRegistry <MongoLamarRegistry>();
            services.For <IFileService>().Use <S3FileService>();
        }
Beispiel #6
0
        public void ConfigureContainer(ServiceRegistry services)
        {
            const string variable = "OPEN_WEATHER_MAP_API_KEY";

            if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(variable)))
            {
                Environment.SetEnvironmentVariable(variable, "fc28830c17565772df3697a3b91bcd47");
            }

            // It's a good practice to avoid registering the infrastructure layer with the upper layers.
            // This can be done using the method below.
            // https://ardalis.com/avoid-referencing-infrastructure-in-visual-studio-solutions
            //
            //const string name = "Way2.Infrastructure.DependencyResolution.dll";
            //var path = Path.Combine(AppContext.BaseDirectory, name);
            //var assembly = Assembly.LoadFrom(path);
            //services.Scan(_ =>
            //{
            //    _.Assembly(assembly);
            //    _.LookForRegistries();
            //});

            services.AddLamar <InfrastructureRegistry>();

            services.AddControllers();

            services.AddHealthChecks();

            services.AddApiVersioning();

            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "API v1", Version = "v1"
                });
                options.OperationFilter <RemoveVersionFromParameter>();
                options.DocumentFilter <ReplaceVersionWithExactValueInPath>();
            });

            services.AddHostedService <DatabaseMigrationHostedService>();
            services.AddHostedService <DatabaseSeedHostedService>();
            services.AddHostedService <WeatherFetcherBackgroundService>();
        }
Beispiel #7
0
 public virtual void ConfigureContainer(ServiceRegistry services)
 {
     services.AddHealthChecks();
     services.AddControllers().AddControllersAsServices();
     services.ConfigureSyrfMassTransit(_configuration, cfg =>
     {
         cfg.AddSagaStateMachines(Assembly.GetEntryAssembly());
         cfg.AddSagas(Assembly.GetEntryAssembly());
     },
                                       (rabbitMqConfig, provider) => { rabbitMqConfig.UseDelayedExchangeMessageScheduler(); }
                                       );
     services.Configure <HealthCheckPublisherOptions>(options =>
     {
         options.Delay     = TimeSpan.FromSeconds(2);
         options.Predicate = check => check.Tags.Contains("ready");
     });
     services.AddSingleton(_configuration.GetSection("MessageBusConfig")
                           .Get <MessageBusConfig>());
     services.IncludeRegistry <SyrfRegistry>();
 }