2019-07-11 15:03:17 -04:00
|
|
|
|
using System.Globalization;
|
2021-02-22 15:35:16 -06:00
|
|
|
|
using Bit.Core.Settings;
|
2019-07-11 16:19:38 -04:00
|
|
|
|
using Bit.Core.Utilities;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.SharedWeb.Utilities;
|
2019-03-02 12:15:28 -05:00
|
|
|
|
using Microsoft.IdentityModel.Logging;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Bit.EventsProcessor;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2019-03-02 12:15:28 -05:00
|
|
|
|
public class Startup
|
|
|
|
|
|
{
|
|
|
|
|
|
public Startup(IWebHostEnvironment env, IConfiguration configuration)
|
|
|
|
|
|
{
|
2019-07-11 15:03:17 -04:00
|
|
|
|
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
|
2019-03-02 12:15:28 -05:00
|
|
|
|
Configuration = configuration;
|
|
|
|
|
|
Environment = env;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IConfiguration Configuration { get; }
|
2020-01-10 08:33:13 -05:00
|
|
|
|
public IWebHostEnvironment Environment { get; set; }
|
2019-03-02 12:15:28 -05:00
|
|
|
|
|
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
|
{
|
2019-07-11 21:45:14 -04:00
|
|
|
|
// Options
|
2019-03-02 12:15:28 -05:00
|
|
|
|
services.AddOptions();
|
2019-07-11 21:45:14 -04:00
|
|
|
|
|
|
|
|
|
|
// Settings
|
2022-03-21 18:13:00 -04:00
|
|
|
|
services.AddGlobalSettingsServices(Configuration, Environment);
|
2019-07-11 21:45:14 -04:00
|
|
|
|
|
|
|
|
|
|
// Hosted Services
|
2019-03-02 12:15:28 -05:00
|
|
|
|
services.AddHostedService<AzureQueueHostedService>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-07-11 16:19:38 -04:00
|
|
|
|
public void Configure(
|
|
|
|
|
|
IApplicationBuilder app,
|
2020-01-10 08:33:13 -05:00
|
|
|
|
IWebHostEnvironment env,
|
|
|
|
|
|
IHostApplicationLifetime appLifetime,
|
2019-07-11 16:19:38 -04:00
|
|
|
|
GlobalSettings globalSettings)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2019-07-11 16:19:38 -04:00
|
|
|
|
IdentityModelEventSource.ShowPII = true;
|
2019-07-23 16:38:49 -04:00
|
|
|
|
app.UseSerilog(env, appLifetime, globalSettings);
|
2021-11-09 11:37:14 -05:00
|
|
|
|
// Add general security headers
|
|
|
|
|
|
app.UseMiddleware<SecurityHeadersMiddleware>();
|
2020-01-10 08:33:13 -05:00
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
2019-03-02 12:15:28 -05:00
|
|
|
|
{
|
2020-01-10 08:33:13 -05:00
|
|
|
|
endpoints.MapGet("/alive",
|
2021-12-09 15:45:45 -05:00
|
|
|
|
async context => await context.Response.WriteAsJsonAsync(System.DateTime.UtcNow));
|
|
|
|
|
|
endpoints.MapGet("/now",
|
|
|
|
|
|
async context => await context.Response.WriteAsJsonAsync(System.DateTime.UtcNow));
|
|
|
|
|
|
endpoints.MapGet("/version",
|
|
|
|
|
|
async context => await context.Response.WriteAsJsonAsync(CoreHelpers.GetVersion()));
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2020-01-10 08:33:13 -05:00
|
|
|
|
});
|
2019-03-02 12:15:28 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|