lingsamuel commented on code in PR #10112:
URL: https://github.com/apache/apisix/pull/10112#discussion_r1311021072
##########
apisix/plugins/example-plugin.lua:
##########
@@ -85,6 +86,27 @@ function _M.access(conf, ctx)
core.log.warn("plugin access phase, conf: ", core.json.encode(conf))
-- return 200, {message = "hit example plugin"}
+ if conf.server_func then
+ -- Example plugin server function call
+ local res, err = core.server_func(conf.server_func, core.json.encode({
+ ["data"] = "body-content"
+ }), {
+ ["Content-Type"] = "application/json",
+ })
+ if not err then
+ core.log.warn("plugin server func result: ", res.body)
+ if res.status == 200 then
+ core.response.set_header("Server-Func-Response", res.body)
Review Comment:
User may need other information, such as res.status
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]