Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个需求,在服务器返回响应,向其他服务器发送请求,但 openresty 说 API 在 body_filter_by_lua* 的上下文中被禁用。我使用模块 resty.http。谢谢
您可以更改主要逻辑。
首先向您的上游发出子请求(location.capture 或 lua-resty-http)
成功后,您可以首先通过 Lua 代码向下游发送响应,然后从 Lua 向您的“其他服务器”发出下一个子请求。
更新 - 这不起作用 作为第二种方法,您可以将“其他服务器”视为上游,并且仅当对原始服务器的子请求成功时才允许向该上游请求。
对于这两种情况,您都可以在 cosocket API 可用的地方使用 access_by_lua* 和 content_by_lua*。