apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.3k stars 2.49k forks source link

docs: update example in serverless Plugin documentation #8980

Open pottekkat opened 1 year ago

pottekkat commented 1 year ago

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"
            ]
        }
Neilblaze commented 1 year ago

@navendu-pottekkat please assign this to me.

github-actions[bot] commented 7 months ago

This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.

kayx23 commented 4 months ago

Would it be sufficient to add two examples (register custom built-in variables and modify specific field in response body), same as the api7 docs, for this issue? If so, I can open a PR.