53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System.Globalization;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
using NodaTime;
|
|
using NodaTime.Serialization.SystemTextJson;
|
|
|
|
namespace DysonNetwork.Messager.Startup;
|
|
|
|
public static class ServiceCollectionExtensions
|
|
{
|
|
public static IServiceCollection AddAppServices(this IServiceCollection services)
|
|
{
|
|
services.AddDbContext<AppDatabase>();
|
|
services.AddHttpContextAccessor();
|
|
|
|
services.AddHttpClient();
|
|
|
|
services
|
|
.AddControllers()
|
|
.AddJsonOptions(options =>
|
|
{
|
|
options.JsonSerializerOptions.NumberHandling =
|
|
JsonNumberHandling.AllowNamedFloatingPointLiterals;
|
|
options.JsonSerializerOptions.PropertyNamingPolicy =
|
|
JsonNamingPolicy.SnakeCaseLower;
|
|
|
|
options.JsonSerializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
|
|
});
|
|
|
|
services.AddGrpc(options =>
|
|
{
|
|
options.EnableDetailedErrors = true;
|
|
});
|
|
services.AddGrpcReflection();
|
|
|
|
return services;
|
|
}
|
|
|
|
public static IServiceCollection AddAppAuthentication(this IServiceCollection services)
|
|
{
|
|
services.AddAuthorization();
|
|
return services;
|
|
}
|
|
|
|
public static IServiceCollection AddAppBusinessServices(
|
|
this IServiceCollection services,
|
|
IConfiguration configuration
|
|
)
|
|
{
|
|
return services;
|
|
}
|
|
}
|