We have a scenario where the config data changes for different users. So we need to fetch config data on every api call from DB.
What I have tried:
In earlier design we have
services.AddInfrastructure(Configuration);
in ConfigureServices under Startup.cs and corresponding code to load config info from appsettings.json file like this:
services.Configure<GoOrdRWebAPI_ConfigurationSetting>(x => configuration.GetSection("GoOrdRWebAPISettings").Bind(x));
Call just requires DI and simple call like this:
string constr = _configs.Value.CentralMySqlConnection;
But now since config info will have to change for every api call ,we cant fetch from appsettings.json.
We tried adding config object from middleware to HttpContext.Request.Headers like this:
ConfigModel conMod = GetConfigDataToContext();
context.Request.Headers.Add("config_data", JsonConvert.SerializeObject(conMod));
But this doesn't seem very secure and handy.
Is there a better way to do this? Preferably something similar to what we did originally(via IServiceCollection) but from Middleware instead of Startup.cs?