porksausages
❔ ASP.NET Core WebAPI Dynamic route mapping at runtime with path parameters
For context, the application I'm working on receives configuration from an external source, and then spins up a WebApi based on that configuration. This works fine with simple definitions, but I’ve hit a brick wall trying to figure out if/how path parameters would be possible at runtime. At the moment I’m currently doing something like this to create the endpoints:
But I have no idea if I could build the handler function, which may have any number of parameters, dynamically. I know it's possible to create DynamicMethods, but I assume the compiler would need to know the signature of the handler at compile time, which would make it impossible to do this in the way that I'm trying to do it. If that assumption is correct, is there an alternative way to achieve this?
2 replies