Open aaron-codes opened 3 years ago
It's not a good way to support it in Apache APISIX but you can implement it in a custom plugin.
see https://apisix.apache.org/docs/apisix/plugins/batch-requests/
Now we support setting the same Query
for different requests, does it make sense to you?
please change the title to English @aaron-codes
That's a feature I would like to see too. Other API gateways call this differently. I've seem them call it Sequential Proxy, Chained Backend Requests, and API Composition, but all of these seems to do the same basic thing. It's not the same as batch requests, because sometimes I need the response from an "upstream backend" to be included in the request of the next "upstream backend" on the pipeline, and I think batch requests only support making concurrent requests that are independent from each other.
The motivation for this feature is simply for the frontend convenience, that's why it may also be called "Backend for Frontend" (I guess that's why, not 100% sure). Specially useful for mobile clients and web apps that need to access micro-apis that separates related entities between them. Instead of making chained requests on every frontend client, why not configure them in the gateway?
@abbluiz Maybe the batch-request plugin can serve this purpose?
the batch-request plugin can sent more multiple requests, but the "Backend for Frontend" here also need to handle responses of multiple requests?
@spacewander @tzssangglass
As I mentioned before, the batch-requests would not fully serve this purpose, because yes it would need to handle a few responses, if some request on the pipeline depends on the response of other requests.
Maybe it will become clear for you if you check the implementation of chained requests other API gateways have done, such as "Sequential Proxy" on KrakenD: https://www.krakend.io/docs/endpoints/sequential-proxy/
But perhaps I am wrong about batch-requests. Please feel free to correct me about its functionality if you still believe it would achieve the same goal I am trying to describe.
I see. To support it, currently we have to write a custom plugin.
@18300618319 suggested that we can study the API orchestration from the other gateways in https://github.com/apache/apisix/issues/5076
fizz-gateway这个API编排挺好用的
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年9月17日(星期五) 上午9:44 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [apache/apisix] request help: Support Backend for Frontend (#4761)
@18300618319建议我们可以研究来自其他网关的 API 编排#5076
— 你收到这个是因为你被提到了。 直接回复此邮件,在 GitHub 上查看或取消订阅. GitHub Mobile 上的分流通知监督办或机器人.
@spacewander
How would I write a custom plugin for this? Would you recommend using the ext-plugin-post-req
with Python, for example? Could I make additional request inside this external plugin?
Yes, you can make additional request inside the external plugin. There is a real-world example (not in Python): https://github.com/swisscom/apisix-opa-plugin/blob/master/auth.go
Or you can do it in the Lua, like https://github.com/apache/apisix/blob/master/apisix/plugins/forward-auth.lua
@spacewander Interesting. I will be trying that out in the future.
Issue description
能否支持下图中的 API 编排能力