Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
54 lines (43 loc) · 1.4 KB
/
Copy pathProgram.cs
File metadata and controls
54 lines (43 loc) · 1.4 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
using KerioControlWeb.Services;
var builder = WebApplication.CreateBuilder(args);
// Äîáàâëåíèå ñåðâèñîâ
builder.Services.AddControllersWithViews();
builder.Services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromHours(2);
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
});
// Ðåãèñòðàöèÿ ñåðâèñîâ
builder.Services.AddSingleton<IKerioApiService, KerioApiService>();
builder.Services.AddSingleton<ILogService, FileLogService>();
builder.Services.AddHttpContextAccessor();
builder.Services.AddScoped<IFileProcessingService, FileProcessingService>();
builder.Services.AddHttpClient("PythonIocService", client =>
{
client.BaseAddress = new Uri("http://localhost:8000");
});
builder.WebHost.UseUrls("http://0.0.0.0:5043", "https://0.0.0.0:7135");
builder.Services.AddHttpClient();
builder.Services.AddSingleton(provider =>
{
var env = provider.GetRequiredService<IWebHostEnvironment>();
var path = Path.Combine(env.ContentRootPath, "Data", "exclude.txt");
return new ExcludeService(path);
});
var app = builder.Build();
// Êîíôèãóðàöèÿ pipeline
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseSession();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();