Is it possible to route request based on value in body using Ocelot? For example:
body:
{
"Token" : 1 // route to http://google.com
}
body:
{
"Token" : 2 // route to http://microsoft.com
}
Is it possible to route request based on value in body using Ocelot?
No this is not possible OTS with Ocelot. I would suggest the best solution would be to promote the "Token" variable into the request header and then do the routing based on request header value, as documented here: https://github.com/ThreeMammals/Ocelot/issues/360#issuecomment-641728037
What do you think about that it can be done in custom load balancer?
I don't know the answer. However what I do know is that proxies such as Ocelot and other gateways/NLBs are usually optimised to read data from URL or headers, not the body. Body can be of any size and serialisation is pretty expensive in terms of resources. This is not the kind of thing you want to be doing for every request, especially in a high volume setup. I would strongly recommend promoting the value(s) you want to route by into the path, query, or header.