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

貢獻者指南