'F# .NetCore Web API - Access AppSettings as IOptions
I'm new to F# and coming from a C# background.
I'm working on a .netcore web api (F#). Here I'm not certain about what is the best way to access appsetting.json values inside functional modules.
In C#, what we do is bind appsettings as custom objects to DI container, from there we can inject the as IOptions<> to any class that we want.
But in the F# world, with functional programming paradigm what would be the technically correct way to access these values?
I'm thinking of these two approaches but not sure whether they are the right way to go.
- Hook it up DI, inject to controller level and from there pass the values as parameters to the functions I need. Not so elegant.
- Hook it up to DI, and implement services as types (with a interfaces) instead of plain functional modules. So that we can inject IOptions<> to these types via constructor. Not so functional programming.
Or is there a better/correct way of doing this all together?
Thanks,
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
