Copilot commented on code in PR #13051:
URL: https://github.com/apache/apisix/pull/13051#discussion_r2922581113


##########
docs/en/latest/plugins/serverless.md:
##########
@@ -47,8 +47,13 @@ Only Lua functions are allowed here and not other Lua code.
 For example, anonymous functions are legal:
 
 ```lua
-return function()
-    ngx.log(ngx.ERR, 'one')
+return function(conf, ctx)
+    local core = require("apisix.core")

Review Comment:
   PR description/issue #8980 asks to update the serverless plugin 
documentation example shown under "Enable Plugin" to demonstrate URI argument 
manipulation, but this change only updates the earlier "anonymous functions are 
legal" snippet. Consider updating the "Enable Plugin" JSON example (and the 
later log-output text) to use this new, more meaningful function so the 
documentation matches the stated goal.



##########
docs/en/latest/plugins/serverless.md:
##########
@@ -47,8 +47,13 @@ Only Lua functions are allowed here and not other Lua code.
 For example, anonymous functions are legal:
 
 ```lua
-return function()
-    ngx.log(ngx.ERR, 'one')
+return function(conf, ctx)
+    local core = require("apisix.core")
+    if not ngx.var.arg_name then
+        local uri_args = core.request.get_uri_args(ctx)

Review Comment:
   The example checks `ngx.var.arg_name` (which corresponds to the `name` query 
parameter) but later sets `uri_args.name`. This mismatch is likely to confuse 
readers; consider either checking `uri_args.name` after calling 
`core.request.get_uri_args(ctx)` or renaming/adjusting the example so the 
checked key and the assigned key clearly match.
   ```suggestion
       local uri_args = core.request.get_uri_args(ctx)
       if not uri_args.name then
   ```



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