aboutsummaryrefslogtreecommitdiff
path: root/dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons/Config.cs
blob: 0ca3547f49d76b6dbf8484ffecf9fb923176af32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
namespace CrupestApi.Commons;

public class CrupestApiConfig
{
    public string DataDir { get; set; } = string.Empty;
}

public static class CrupestApiConfigExtensions
{
    public static IServiceCollection AddCrupestApiConfig(this IServiceCollection services)
    {
        services.AddOptions<CrupestApiConfig>().BindConfiguration("CrupestApi");
        services.PostConfigure<CrupestApiConfig>(config =>
        {
            if (config.DataDir is null || config.DataDir.Length == 0)
            {
                config.DataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "crupest-api");
            }
        });

        return services;
    }
}