{"id":13776217,"url":"https://github.com/api7/lua-var-nginx-module","last_synced_at":"2025-04-06T02:19:52.828Z","repository":{"id":44918953,"uuid":"189225096","full_name":"api7/lua-var-nginx-module","owner":"api7","description":"Fetch nginx variable by FFI way for OpenResty which is faster","archived":false,"fork":false,"pushed_at":"2022-07-27T01:38:09.000Z","size":52,"stargazers_count":52,"open_issues_count":1,"forks_count":19,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-02-13T20:25:46.861Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.apiseven.com","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/api7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-29T12:53:30.000Z","updated_at":"2023-10-18T21:21:56.000Z","dependencies_parsed_at":"2022-09-17T16:02:27.432Z","dependency_job_id":null,"html_url":"https://github.com/api7/lua-var-nginx-module","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/api7%2Flua-var-nginx-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/api7%2Flua-var-nginx-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/api7%2Flua-var-nginx-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/api7%2Flua-var-nginx-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/api7","download_url":"https://codeload.github.com/api7/lua-var-nginx-module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423940,"owners_count":20936691,"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":[],"created_at":"2024-08-03T18:00:19.505Z","updated_at":"2025-04-06T02:19:52.802Z","avatar_url":"https://github.com/api7.png","language":"Perl","readme":"lua-var-nginx-module\n====================\n\nFetchs Nginx variable by Luajit with FFI way which is fast and cheap.\n\nCompares to `ngx.var.*`, performance has increased by more than five times. ^_^\n\n\nTable of Contents\n=================\n* [Install](#install)\n* [Methods](#methods)\n    * [request](#request)\n    * [fetch](#fetch)\n* [TODO](#todo)\n\n\nInstall\n=======\n\nCompiles the nginx c module to OpenResty:\n\n```shell\n./configure --prefix=/opt/openresty \\\n         --add-module=/path/to/lua-var-nginx-module\n```\n\nInstall the Lua source code, there are two ways:\n\n```shell\nluarocks install lua-resty-ngxvar\n```\n\nOr we can copy the source lua file to specified directory which OpenResty can\nload it normally.\n\n```shell\nmake install LUA_LIB_DIR=/opt/openresty/lualib/\n```\n\nMethod\n======\n\n### request\n\n`syntax: req = ngxvar.request()`\n\nReturns the request object of current request. We can cache it at your Lua code\nland if we try to fetch more than one variable in one request.\n\n[Back to TOC](#table-of-contents)\n\n### fetch\n\n`syntax: val = ngxvar.fetch(name, req)`\n\nReturns the Nginx variable value by name.\n\n```nginx\n location /t {\n     content_by_lua_block {\n         local var = require(\"resty.ngxvar\")\n         local req = var.request()\n\n         ngx.say(var.fetch(\"host\", req))\n         ngx.say(var.fetch(\"uri\", req))\n     }\n }\n```\n\n[Back to TOC](#table-of-contents)\n\nTODO\n====\n\n* support more variables.\n\n[Back to TOC](#table-of-contents)\n","funding_links":[],"categories":["Modules"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapi7%2Flua-var-nginx-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapi7%2Flua-var-nginx-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapi7%2Flua-var-nginx-module/lists"}