Changing route settings in runtime #872
-
What should we add or change to make your life better?Add some options to change route configurations in runtime. For example, for Hosts in my route configuration: I would like to have a default configuration for any tenant in my infrastructure and change its setting based on a HTTP request, header, etc. It can be a placeholder:
Why is this important to you?I can create a default configuration and reduce the size of my configuration for all tenants that I have in my repository. It's similar to what I try to do in this thread #841. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 1 reply
-
There is the extensibility to update configuration at runtime, but that by necessity uses a snapshot model so that its not suitable to do on a per-request basis. |
Beta Was this translation helpful? Give feedback.
-
Did you try the IProxyConfigFilter? |
Beta Was this translation helpful? Give feedback.
-
Thanks, @samsp-msft for the explanation. @Tratcher ... about IProxyConfigFilter... I can change the configuration load, right? is it possible to change the route configuration when a request to proxy happens? |
Beta Was this translation helpful? Give feedback.
-
Right, IProxyConfigFilter changes the config on load, not per request. If you want to change the route's host parameter to match the incoming request then why even set the host on the route, it's an optional field? Can you give a specific example of how changing the host match per request would help? |
Beta Was this translation helpful? Give feedback.
-
Sure @Tratcher ... I have a lot of proxy consumers that will access their backend APIs by different host's address. For example, I have consumers A and B that should use the hosts abc.com and def.com respectively to call their backend APIs. In their backend API, all of them have the same API contracts, headers, security policies, etc. However in different hosts address. When they are exposed by proxy (YARP), we must keep the hosts address and other configurations to not break the consumers. In the YARP configuration, we need to set the Route and Cluster configuration for each consumer, which creates a bigger configuration file and duplicated some common information, like Transformations. So, If I have the possibility to identify the consumer and apply all settings in runtime mode, beyond decreasing my repository size to store all configuration, my complexity to update Routes and Clusters configurations will be low too. Basically, what I am trying to do is "reuse" the "same" configuration with +70 consumers by applying some changes at the HTTP request moment. |
Beta Was this translation helpful? Give feedback.
-
So if all the customers have their own host name externally, but the internal API doesn't care, why do you need a unique config/route for each customer? It seems like you would leave the Host off the route entirely, using one route to proxy all requests to the destination. What does the config for a specific customer look like now? |
Beta Was this translation helpful? Give feedback.
-
I have different consumer by external host and I decide to route any of them to special backend just by Host name and this route can change in runtime . is yarp suitable for this scenario? |
Beta Was this translation helpful? Give feedback.
Did you try the IProxyConfigFilter?