Ejemplo n.º 1
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);
     });
 }
        // 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()));
        }