spacewander commented on issue #5662: URL: https://github.com/apache/apisix/issues/5662#issuecomment-983483497
The custom function should be wrapped with `return function(conf, ctx) ... end` in the code block. See https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/serverless.md#how-to-enable ``` curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "uri": "/index.html", "plugins": { "serverless-pre-function": { "phase": "rewrite", "functions" : ["return function() ngx.log(ngx.ERR, \"serverless pre function\"); end"] }, "serverless-post-function": { "phase": "rewrite", "functions" : ["return function(conf, ctx) ngx.log(ngx.ERR, \"match uri \", ctx.curr_req_matched and ctx.curr_req_matched._path); end"] # ^-- wrap the function }, }, "upstream": { "type": "roundrobin", "nodes": { "127.0.0.1:1980": 1 } } }' ``` And remember to keep the whitespace, so it can be a valid Lua code. I suggest using a script to generate the JSON instead of editing it manually. -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org