/// <summary> /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app"></param> /// <param name="env"></param> public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env) { string aggregationPipelinesPath = Path.Combine(dataPath, "AggregationPipelines"); string configFilePath = Path.Combine(dataPath, "MongoDB", "MongoConfig.xml"); string credentialFilePath = Path.Combine(dataPath, "MongoDB", "MongoCredentials.xml"); MongoManager.Configure(aggregationPipelinesPath, configFilePath, credentialFilePath); log.Information($"{BaseSettings.ApiName} started. Version = [{BaseSettings.ApiVersion}]."); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); log.Information("Development Env enabled."); } else { log.Information("Production Env enabled."); } // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(c => c.RouteTemplate = $"/{BaseSettings.SwaggerBaseUrl}/swagger/{{documentName}}/swagger.json"); //app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("swagger/v1/swagger.json", $"{BaseSettings.ApiName} {BaseSettings.ApiVersion}"); c.RoutePrefix = BaseSettings.SwaggerBaseUrl; }); app.UseRouting(); app.UseCors(builder => builder.WithOrigins(Configuration.GetSection("AppConfiguration:corsOrigins").Get <string[]>()).AllowAnyHeader().AllowAnyMethod().AllowCredentials()); app.UseAuthorization(); }
public virtual void Initialize() { if (!IsMongoNeeded) { return; } string aggregationPipelinesPath = Path.Combine(dataPath, "AggregationPipelines"); string configFilePath = Path.Combine(dataPath, "MongoDB", "MongoConfig.xml"); string credentialFilePath = Path.Combine(dataPath, "MongoDB", "MongoCredentials.xml"); if (MongoManager.aggregationPipelinesLoader.Aggregates == null || MongoManager.aggregationPipelinesLoader.Aggregates.Count == 0) { MongoManager.Configure(aggregationPipelinesPath, configFilePath, credentialFilePath); } }