geqintan commited on
Commit
bc53247
·
1 Parent(s): 97f80cf
Files changed (2) hide show
  1. app/v1/app.lua +1 -60
  2. app_v1.lua +0 -1
app/v1/app.lua CHANGED
@@ -1,60 +1 @@
1
- -- 这是一个单行注释
2
-
3
- --[[
4
- 这是一个多行注释
5
- 这是一个多行注释
6
- ]]
7
- local uri = ngx.var.uri
8
-
9
- local api_version = ''
10
- local api_pxoxy_pass_url_indicator = ''
11
-
12
- -- 提取版本号和 proxy_pass url 标识
13
- if uri == '/' then -- uri为 / ,退出运行
14
- ngx.exit(ngx.HTTP_OK)
15
- end
16
-
17
- local api_version, api_pxoxy_pass_url_indicator = uri:match("/([^/]+)/(.*)")
18
-
19
- ngx.say("api_version: ", api_version)
20
- ngx.say("api_pxoxy_pass_url_indicator: ", api_pxoxy_pass_url_indicator)
21
- pass_url = api_pxoxy_pass_url_indicator
22
- pass_url = pass_url:gsub("http/", "http://")
23
- pass_url = pass_url:gsub("https/", "https://")
24
- ngx.say("pass_url: ", pass_url)
25
-
26
- -- 根据版本号加载不同的 Lua 文件
27
- -- local lua_path = "app_" .. api_version
28
- -- ngx.say("lua_path: ", lua_path)
29
- -- require(lua_path)
30
- local lua_path = "app/" ..api_version .. "/app"
31
- ngx.say("lua_path: ", lua_path)
32
- require(lua_path)
33
-
34
- -- local lfs = require("lfs")
35
- -- -- 获取当前工作目录
36
- -- local current_dir = lfs.currentdir()
37
- -- ngx.say("Current directory:", current_dir)
38
- -- -- 列举当前目录的内容
39
- -- for file in lfs.dir(current_dir) do
40
- -- if file ~= "." and file ~= ".." then -- 排除 "." 和 ".."
41
- -- local path = current_dir .. "/" .. file
42
- -- local attr = lfs.attributes(path) -- 获取文件属性
43
-
44
- -- if attr.mode == "directory" then
45
- -- print("Directory:", file)
46
- -- elseif attr.mode == "file" then
47
- -- print("File:", file)
48
- -- else
49
- -- print("Other:", file)
50
- -- end
51
- -- end
52
- -- end
53
-
54
-
55
- -- local status, err = pcall(require, lua_path)
56
- -- if not status then
57
- -- ngx.log(ngx.ERR, "failed to load lua file: ", lua_path, ", error: ", err)
58
- -- ngx.say("Error: Failed to load API version: ", api_version)
59
- -- ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
60
- -- end
 
1
+ ngx.say("version: v1")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app_v1.lua DELETED
@@ -1 +0,0 @@
1
- ngx.say("version: v1")