tao12345666333 commented on code in PR #10112:
URL: https://github.com/apache/apisix/pull/10112#discussion_r1309507319


##########
apisix/plugins/example-plugin.lua:
##########
@@ -27,6 +27,7 @@ local schema = {
         t = {type = "array", minItems = 1},
         ip = {type = "string"},
         port = {type = "integer"},
+        server_func = {type = "string"},

Review Comment:
   rename it to `func_name` ?



##########
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:
   return the response body?



-- 
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]

Reply via email to