I'm using library that creates builder in this way
var webApiOptions = new AkaAppOptions<ApiOptions>(ApplicationId, authenticationType);
var builder = new AkaAppBuilder<ApiOptions>(args, webApiOptions);
now this builder contains IConfiguration
that I need.
My problem is that I need to read configuration to know what kind of authenticationType
it is. this happens before I have a WebApplicationBuilder
.
My options are to create temporary WebApplicationBuilder
, read configuration and then create this library builder, drawback here is memory I guess.
And another option is to read appsettings.json
manually to get that information/ drawback is memory and memory environment appsettings?
Which one to read
So for example I would do something like this to create temporary builder and than the one I need
var tempBuilder = WebApplication.CreateBuilder(args);
var useExternalAuth = tempBuilder.Configuration.GetSection("ExternalAuth").Exists();
var authenticationType = useExternalAuth ? AuthenticationType.ExternalService : AuthenticationType.Service;
var webApiOptions = new AkaAppOptions<ApiOptions>(ApplicationId, authenticationType);
var builder = new AkaAppBuilder<ApiOptions>(args, webApiOptions);
Are there any other options?