-
Notifications
You must be signed in to change notification settings - Fork 3
/
Startup.cs
58 lines (50 loc) · 1.84 KB
/
Startup.cs
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
using System.Globalization;
using Microsoft.AspNetCore.Localization;
using OryAdmin.Components;
using OryAdmin.Services;
namespace OryAdmin;
public class Startup(IConfigurationRoot config, IWebHostEnvironment env)
{
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton(typeof(ILogger), provider => provider.GetRequiredService<ILogger<Program>>());
services.AddHttpContextAccessor();
services.AddRazorComponents()
.AddInteractiveServerComponents();
// localisation
services.AddLocalization(options => options.ResourcesPath = "Resources");
services.AddSingleton<ICustomTranslator, CustomTranslator>();
// own services
services.AddSingleton<EnvService>();
services.AddSingleton<ApiService>();
services.AddSingleton<IdentitySchemaService>();
}
public Task Configure(WebApplication app)
{
// localisation
var supportedCultures = new[]
{
new CultureInfo("en"),
new CultureInfo("de")
};
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("de"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
});
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios,
// see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseStaticFiles();
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
return Task.CompletedTask;
}
}