We have an API built using ASP.Net Core, and we would like to consolidate multiple requests into one HTTP requests for performance reasons.
In previous versions of asp.net you could allow for batch requests via the DefaultHttpBatchHandler.
Unfortunately, no such thing seems to exist in Asp.net Core.
Is anyone aware of any way to do HTTP batches in core?
2 Answers
Answers 1
After doing my research on the matter, this seems fairly simple to implement. However, I think it should be supported by the official asp.net core team.
To me it seems like it requires a middleware creating multiple RouteContext
according to the inputted text, and just invoking their Handlers - and modifying their response. it might be a little bit more difficult, because it would require support for multiple responses for an HttpContext
(as far as I know it seems like it will be shared across Controllers).
Anyway, There is an open issue in the official repository that I have risen from the dead, hoping it will move things along. I might work on an implementation in the future if there are no changes soon.
Answers 2
Not sure I understand? Do you mean 1 exposed endpoint that makes multiple calls?
Can you not have 1 API action that just creates multiple Tasks (that will run in parallel), waits for them all to complete then return all response data (combined or separated as required)?
0 comments:
Post a Comment