-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
60 lines (49 loc) · 1.99 KB
/
Program.cs
File metadata and controls
60 lines (49 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using PollingJobToken.AppModels;
using PollingJobToken.AppServices;
using PollingJobToken.Services;
using Scalar.AspNetCore;
using System.Text.Json.Serialization;
namespace PollingJobToken;
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Configure single-line console logging
builder.Logging.ClearProviders();
builder.Logging.AddSimpleConsole(options =>
{
options.SingleLine = true;
options.TimestampFormat = "yyyy-MM-ddTHH:mm:ss.fffZ ";
options.UseUtcTimestamp = true;
});
// Add services to the container.
builder.Services
.AddControllers()
.AddJsonOptions(options =>
{
// Serialize enums as strings globally
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
builder.Services.AddMemoryCache();
// Use desired JobStore implementation - only one should be registered
//builder.Services.AddSingleton<IJobStore, ConcurrentDictionaryJobStore>();
builder.Services.AddSingleton<IJobStore, MemoryCacheJobStore>();
// Register processors
builder.Services.AddSingleton<IJobProcessor<WeatherForecastRequest, WeatherForecastResponse>, WeatherForecastJobProcessor>();
builder.Services.AddSingleton<IJobProcessor<LotteryNumberRequest, LotteryNumberResponse>, LotteryNumberJobProcessor>();
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
var app = builder.Build();
// Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment())
//{
app.MapOpenApi();
app.MapScalarApiReference();
//}
//app.UseHttpsRedirection(); // Disabled for simplicity in local testing
app.UseAuthorization();
app.MapControllers();
app.Run();
}
}