✅ Minimal API: Pass app config to IEndpointRouteBuilder
I am using route builders to map routes for a minimal API, like this:
I'd like to access the app's IConfiguration from within these classes and am hoping there is a better way than reading config values in
Program
and passing them to each register endpoints method. I'd really like to receive config values or IConfiguration as ctor parameters.2 Replies
Would making your extension method off of
WebApplication
instead be viable?
This snippet is from my toy web appThanks, it looks like it would be, as
WebApplication
also seems to implement IEndpointRouteBuilder
, allowing me to call app.MapGroup
. I'll have to have a look in a short while.