apache/apisix

docs: update example in serverless Plugin documentation

已关闭

#8,980 创建于 2023年3月1日

 (3 条评论) (0 个反应) (0 位负责人)Lua (2,860 个派生)batch import
docgood first issue

仓库指标

星标
 (16,597 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Current State

The current documentation of the serverless Plugin shows a simple example of a log function:

return function() ngx.log(ngx.ERR, \"serverless pre function\"); end 

Desired State

This could be updated with a non-trivial example that could show the capabilities of the Plugin better:

        "serverless-pre-function": {
            "phase": "rewrite",
            "functions" : [
                "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)
                        uri_args.name = \"world\"
                        ngx.req.set_uri_args(uri_args)
                    end
                end"
            ]
        }

贡献者指南