{"id":27082422,"url":"https://github.com/tokers/lua-resty-ctxdump","last_synced_at":"2025-04-06T02:47:07.507Z","repository":{"id":55016536,"uuid":"92246714","full_name":"tokers/lua-resty-ctxdump","owner":"tokers","description":"Stash and apply the old ngx.ctx for avoiding being destoried after Nginx internal redirect happens.  ","archived":false,"fork":false,"pushed_at":"2021-01-15T01:02:21.000Z","size":12,"stargazers_count":42,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-03-02T05:31:07.098Z","etag":null,"topics":["lua","lua-resty","nginx","openresty"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tokers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-24T03:40:13.000Z","updated_at":"2022-11-16T10:19:11.000Z","dependencies_parsed_at":"2022-08-14T09:10:30.877Z","dependency_job_id":null,"html_url":"https://github.com/tokers/lua-resty-ctxdump","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokers%2Flua-resty-ctxdump","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokers%2Flua-resty-ctxdump/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokers%2Flua-resty-ctxdump/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokers%2Flua-resty-ctxdump/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tokers","download_url":"https://codeload.github.com/tokers/lua-resty-ctxdump/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247426984,"owners_count":20937197,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","lua-resty","nginx","openresty"],"created_at":"2025-04-06T02:47:06.748Z","updated_at":"2025-04-06T02:47:07.495Z","avatar_url":"https://github.com/tokers.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"Name\n====\n\nlua-resty-ctxdump - stash and apply the ngx.ctx, avoiding being destoried after Nginx internal redirect happens.\n\n![Build Status](https://travis-ci.org/tokers/lua-resty-ctxdump.svg?branch=master)\n\nTable of Contents\n=================\n\n* [Name](#name)\n* [Status](#status)\n* [Synopsis](#synopsis)\n* [Methods](#methods)\n    * [stash_ngx_ctx](#stash_ngx_ctx)\n    * [apply_ngx_ctx](#apply_ngx_ctx)\n* [Author](#author)\n* [Copyright and License](#copyright-and-license)\n* [See Also](#see-also)\n\nStatus\n======\n\nProbably production ready in most cases, though not yet proven in the wild.  Please check the issues list and let me know if you have any problems / questions.\n\nSynopsis\n========\n\n```lua\n\nlocation /t1 {\n    set $ctx_ref \"\";\n    content_by_lua_block {\n        local ctxdump = require \"resty.ctxdump\"\n        ngx.ctx = {\n            Date = \"Wed May  3 15:18:04 CST 2017\",\n            Site = \"unknown\"\n        }\n        ngx.var.ctx_ref = ctxdump.stash_ngx_ctx()\n        ngx.exec(\"/t2\")\n    }\n}\n\nlocation /t2 {\n    internal;\n    content_by_lua_block {\n        local ctxdump = require \"resty.ctxdump\"\n        ngx.ctx = ctxdump.apply_ngx_ctx(ngx.var.ctx_ref)\n        ngx.say(\"Date: \" .. ngx.ctx[\"Date\"] .. \" Site: \" .. ngx.ctx[\"Site\"])\n    }\n}\n\n```\n\nMethods\n=======\n\nstash_ngx_ctx\n-------------\n\n**syntax:** *ref = stash_ngx_ctx()* \u003cbr\u003e\n**phase:** *init_worker_by_lua\\*, set_by_lua\\*, rewrite_by_lua\\*, access_by_lua\\*,\n    content_by_lua\\*, header_filter_by_lua\\*, body_filter_by_lua\\*, log_by_lua\\*,\n    ngx.timer.\\*, balancer_by_lua\\* \n    \nReference the `ngx.ctx`, returns an anchor(a new reference maintained by lua-resty-ctxdump).\n\nNote: `stash_ngx_ctx` and `apply_ngx_ctx` must be called in pairs, otherwise memory leak will happen! See [apply_ngx_ctx](#apply_ngx_ctx).\n\napply_ngx_ctx\n-------------\n\n**syntax:** *old_ngx_ctx = apply_ngx_ctx(ref)* \u003cbr\u003e\n**phase:** *init_worker_by_lua\\*, set_by_lua\\*, rewrite_by_lua\\*, access_by_lua\\*,\n    content_by_lua\\*, header_filter_by_lua\\*, body_filter_by_lua\\*, log_by_lua\\*,\n    ngx.timer.\\*, balancer_by_lua\\* \n    \nfetch the old `ngx.ctx` with the anchor returns from `stash_ngx_ctx `. After that, the anchor will be out of work.\n\nNote: `stash_ngx_ctx` and `apply_ngx_ctx ` must be called in pairs, otherwise memory leak will happen! See [stash_ngx_ctx](#stash_ngx_ctx).\n\n\nAuthor\n======\n\nAlex Zhang(张超) tokers@apache.org, @api7.ai.\n\n\nCopyright and License\n=====================\n\nThe bundle itself is licensed under the 2-clause BSD license.\n\nCopyright (c) 2017-2021, Alex Zhang.\n\nThis module is licensed under the terms of the BSD license.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n* Redistributions of source code must retain the above copyright notice, this\nlist of conditions and the following disclaimer.\n* Redistributions in binary form must reproduce the above copyright notice, this\nlist of conditions and the following disclaimer in the documentation and/or\nother materials provided with the distribution.\n\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\nTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nHOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\nTO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nSee Also\n========\n\n* upyun-resty: https://github.com/upyun/upyun-resty\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokers%2Flua-resty-ctxdump","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftokers%2Flua-resty-ctxdump","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokers%2Flua-resty-ctxdump/lists"}