-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Request Aggregation #1069
Comments
@stefanvoicila here is the sample. |
Is this issue resolved? I am fairly new to Ocelot and what I could understand if we are aggregating two service calls and the key is same, then it can be handled via the reroute stuff. |
…1826) * Cleanup of Multiplexing middleware, avoiding creating copies of the Http context if only one downstream route. * updating comments * preparing rebase, it's a hack. * fixing test case "Copy_User_ToTarget", method name has changed. * adding some unit tests, checking that if 1 route, ProcessSingleRoute is called and no copies of context are made, if more than 2 Map is called, then more than 2 copies are created. * Applying refactoring suggested. * some code cleanup * Some code cleanup in Aggregate Logic * Cleanup in Aggregate Tests, verifying multiplexer cleanup * Finalizing unit test, with complex keys. * some code refactoring and applying suggestions from reviews * Update requestaggregation.rst Recover docs * updating docs * Update requestaggregation.rst * Update requestaggregation.rst * Code review by @raman-m * Inherit `Steps` functionality instead of private aggregation --------- Co-authored-by: Raman Maksimchuk <dotnet044@gmail.com>
Expected Behavior / New Feature
I am trying to aggregate two requests in a way in which a value from the first response is used in the second response as a parameter.
I want to return the results from both requests in a way that resembles something like this:
"Response": [
FirstResponse_FirstItem:{
"Key": 1,
SecondResponse_Item1: {
"ForeignKey": 1,
"Value" : "aaaaa"
}
}
]
Actual Behavior / Motivation for New Feature
I've been trying to set up an aggregator to do this implementing IDefinedAggregator (as described in the docs) but I had no success. Also, I am struggling to find examples of aggregators in order to have any starting points or ideas on how to do this.
Steps to Reproduce the Problem
config:
{
"ReRoutes": [
{
"DownstreamPathTemplate": "/api/{everything}",
"UpstreamPathTemplate": "/api/logistics/{everything}",
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ],
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5001
}
],
"SwaggerKey": "Logistics"
},
{
"DownstreamPathTemplate": "/api/{everything}",
"UpstreamPathTemplate": "/api/identity/{everything}",
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ],
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 50026
}
],
"SwaggerKey": "Identity"
},
{
"DownstreamPathTemplate": "/api/Buildings",
"UpstreamPathTemplate": "/buildings",
"UpstreamHttpMethod": [ "Get" ],
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5001
}
],
"Key": "buildings"
},
{
"DownstreamPathTemplate": "/api/Device/{Id}",
"UpstreamPathTemplate": "/devices/{Id}",
"UpstreamHttpMethod": [ "Get" ],
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5001
}
],
"Key": "devices"
}
],
"SwaggerEndPoints": [
{
"Key": "Logistics",
"Config": [
{
"Name": "Logistics API",
"Version": "v1",
"Url": "https://localhost:5001/swagger/v1/swagger.json"
}
]
},
{
"Key": "Identity",
"Config": [
{
"Name": "Identity API",
"Version": "v1",
"Url": "https://localhost:50026/swagger/v1/swagger.json"
}
]
}
],
"Aggregates": [
{
"ReRouteKeys": [
"devices",
"buildings"
],
"UpstreamPathTemplate": "/both",
"Aggregator": "TestAggregator"
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost"
}
}
Startup:
services.AddOcelot(Configuration).AddSingletonDefinedAggregator();
Aggregator:
public class TestAggregator : IDefinedAggregator
{
public async Task Aggregate(List responses)
{
??
}
}
Specifications
The text was updated successfully, but these errors were encountered: