2019-07-11 15:03:17 -04:00
|
|
|
|
using System.Globalization;
|
2019-07-11 16:19:38 -04:00
|
|
|
|
using Bit.Core;
|
|
|
|
|
|
using Bit.Core.Utilities;
|
2019-07-11 15:03:17 -04:00
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
2019-03-02 12:15:28 -05:00
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
2019-08-03 23:16:31 -04:00
|
|
|
|
using Microsoft.AspNetCore.Http;
|
2019-03-02 12:15:28 -05:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
using Microsoft.IdentityModel.Logging;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Bit.EventsProcessor
|
|
|
|
|
|
{
|
|
|
|
|
|
public class Startup
|
|
|
|
|
|
{
|
|
|
|
|
|
public Startup(IHostingEnvironment 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; }
|
|
|
|
|
|
public IHostingEnvironment Environment { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2019-07-23 16:38:49 -04:00
|
|
|
|
services.AddGlobalSettingsServices(Configuration);
|
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,
|
|
|
|
|
|
IHostingEnvironment env,
|
|
|
|
|
|
IApplicationLifetime appLifetime,
|
|
|
|
|
|
GlobalSettings globalSettings)
|
2019-03-02 12:15:28 -05: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);
|
2019-08-03 23:16:31 -04:00
|
|
|
|
app.Map("/alive", HandleMapAlive);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void HandleMapAlive(IApplicationBuilder app)
|
|
|
|
|
|
{
|
|
|
|
|
|
app.Run(async context => await context.Response.WriteAsync(System.DateTime.UtcNow.ToString()));
|
2019-03-02 12:15:28 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|