Skip to content
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

request help: Support Backend for Frontend #4761

Open
aaron-codes opened this issue Aug 5, 2021 · 13 comments
Open

request help: Support Backend for Frontend #4761

aaron-codes opened this issue Aug 5, 2021 · 13 comments
Labels
enhancement New feature or request

Comments

@aaron-codes
Copy link

Issue description

能否支持下图中的 API 编排能力
image

@tokers
Copy link
Contributor

tokers commented Aug 5, 2021

It's not a good way to support it in Apache APISIX but you can implement it in a custom plugin.

@juzhiyuan
Copy link
Member

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?

@membphis
Copy link
Member

membphis commented Aug 8, 2021

please change the title to English @aaron-codes

@aaron-codes aaron-codes changed the title request help: API 编排需求实现 request help: Support Backend for Frontend Aug 9, 2021
@abbluiz
Copy link

abbluiz commented Sep 2, 2021

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?

@spacewander
Copy link
Member

@abbluiz
Maybe the batch-request plugin can serve this purpose?

@tzssangglass
Copy link
Member

tzssangglass commented Sep 9, 2021

the batch-request plugin can sent more multiple requests, but the "Backend for Frontend" here also need to handle responses of multiple requests?

@abbluiz
Copy link

abbluiz commented Sep 10, 2021

@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.

@spacewander
Copy link
Member

I see. To support it, currently we have to write a custom plugin.

@spacewander spacewander added the enhancement New feature or request label Sep 10, 2021
@spacewander
Copy link
Member

@18300618319 suggested that we can study the API orchestration from the other gateways in #5076

@zgLiuBing
Copy link

zgLiuBing commented Sep 17, 2021 via email

@abbluiz
Copy link

abbluiz commented Jan 11, 2022

@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?

@spacewander
Copy link
Member

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

@abbluiz
Copy link

abbluiz commented Jan 12, 2022

@spacewander Interesting. I will be trying that out in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants