apache/apisix

docs: update example in serverless Plugin documentation

Open

#8.980 geöffnet am 1. März 2023

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Lua (2.860 Forks)batch import
docgood first issue

Repository-Metriken

Stars
 (16.597 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 8h) (109 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide