Other Kong's ngx.ctx in pdk

In 1.0.0, i see that there are functions to interact with router, service, and consumer which is set by kong in ngx.ctx variables on runloop.
Can we also get kong’s other ctx variables such as router_matches, KONG_PROXIED, and others that might be used by custom plugins.

In my case, my api is usually defined in swagger. When exposing the api through kong, i usually only define swagger’s basePath in route’s path. Then, any custom plugins that might need to know the swagger operations invoked when the api is consumed need to read ngx.ctx.route_matches first and use it to slice the request_uri.
Another of my plugins also need to know whether the request has been proxied or not (e,g. terminated by other plugins).

So i think it might be beneficial to add any other ctx data that is set by kong for custom plugins development

Have a look at https://docs.konghq.com/1.0.x/pdk/kong.ctx/#kongctxshared; it sounds like what you’re looking to do (share ngx.ctx data between plugins).

what i mean is for kong to specify additional api in the PDK to expose ctx variables that are set by kong. for example adding kong.router.get_matches() to return ngx.ctx.router_matches, so that custom plugins do not need to access ngx.ctx.router_matches directly as there is no forward compatibility.


Yes, such APIs are planned in the future, but we do not have a timeline for it yet.

PRs welcome!

1 Like