apache/apisix

docs: update example in serverless Plugin documentation

クローズ

#8,980 opened on 2023/03/01

 (3 件のコメント) (0 件のリアクション) (0 人の担当者)Lua (2,860 件のフォーク)batch import
docgood first issue

Repository metrics

Stars
 (16,597 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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

コントリビューターガイド