My ocelot config looks like below (only relevant parts):
"Routes": [
{
"DownstreamPathTemplate": "/api/service1/json/{pageSize}/{pageNo}/all/{partnerId}",
"DownstreamScheme": "http",
"UpstreamPathTemplate": "/a",
"UpstreamHttpMethod": [ "Get" ],
"ServiceName": "Service1",
"LoadBalancerOptions": {
"Type": "LeastConnection"
},
"Key": "v0-service1",
"Priority": 1
},
{
"DownstreamPathTemplate": "/api/service2/json/{pageSize}/{pageNo}/{partnerId}",
"DownstreamScheme": "http",
"UpstreamPathTemplate": "/b",
"UpstreamHttpMethod": [ "Get" ],
"ServiceName": "Service2",
"LoadBalancerOptions": {
"Type": "LeastConnection"
},
"Key": "v0-service2",
"Priority": 1
}
],
"Aggregates": [
{
"RouteKeys": [
"v0-service1",
"v0-service2"
],
"UpstreamPathTemplate": "/api/services/{partnerId}?pageNo={pageNo}&pageSize={pageSize}",
"Aggregator": "GetDataAggregator"
}
]
The aggregator, for the time being, is defined as follows:
public class GetOffersAggregator : IDefinedAggregator
{
public async Task<DownstreamResponse> Aggregate(List<HttpContext> responses)
{
var readers = responses.Select(r => new StreamReader(r.Response.Body)).ToList();
var objects = await Task.WhenAll(readers.Select(r => r.ReadToEndAsync()));
readers.ForEach(r => r.Dispose());
throw new NotImplementedException();
}
}
Now, if I put a breakpoint in both of the downstream services, it gets hit when I call out to "/api/services/{partnerId}?pageNo={pageNo}&pageSize={pageSize}"
. The issue is that both responses are 404 (even api gateway console logs 200 OK responses which is right, because both breakpoints are getting hit and services are returning data). If I inspect HttpContext
s passed to my aggregator, I can see that the request object contains totally wrong address. It all looks as if the Ocelot was correctly invoking my endpoints but at the same time invoking some non existent ones and passing their results to my aggregator. Any ideas?
EDIT:
I can see my services responses inside the Items property of a HttpContext. Damn, it really looks like some serious error on the library authors side, or is it by design?