diff --git a/audio_convert.lua b/audio_convert.lua new file mode 100644 index 0000000..b5d848d --- /dev/null +++ b/audio_convert.lua @@ -0,0 +1,49 @@ +local cjson = require "cjson" +local http = require "resty.http" + +local TaskTypes = { + NOOP = 'NOOP', + AUDIO_CONVERT = "AUDIO_CONVERT" +} + +local task_server = ngx.var.task_server +local htyuc = ngx.var.htyuc +local host = ngx.var.host + +ngx.log(ngx.INFO, "TASK_SERVER -> ", task_server) +ngx.log(ngx.INFO, "HTYUC -> ", htyuc) +ngx.log(ngx.INFO, "HOST -> ", host) + +ngx.log(ngx.INFO, "URL -> ", ngx.var.uri) + +local sudoerToken = ngx.req.get_headers().HtySudoerToken +local htyhostHeader = ngx.req.get_headers().HtyHostHeader + +local httpc = http.new() + +local remote_url = string.format("%s/api/v1/uc/wx/get_access_token", htyuc) +ngx.log(ngx.INFO, 'remote_url -> ', remote_url) +ngx.log(ngx.INFO, 'HtyHostHeader -> ', htyhostHeader) +ngx.log(ngx.INFO, 'HtySudoerToken -> ', sudoerToken) + +local res, err = httpc:request_uri( + remote_url, + { + method = "GET", + headers = { + ["HtyHostHeader"] = htyhostHeader, + ["HtySudoerToken"] = sudoerToken, + }, + body = body_text, + } +) +if res == nil then + ngx.log(ngx.ERR, "FAILED TO CONNECT TO *HTYUC*", err) +end + +if 201 ~= res.status then + ngx.log(ngx.ERR, "GET ACCESS TOKEN *FAILED*", err) + ngx.say(err) + ngx.exit(res.status) +end +ngx.say(res.body) \ No newline at end of file diff --git a/music-room-dev.conf b/music-room-dev.conf index f427924..0680c16 100644 --- a/music-room-dev.conf +++ b/music-room-dev.conf @@ -35,6 +35,10 @@ server { location /api/ngx/image/combine { content_by_lua_file $resty_loc/resty_funcs/combine.lua; } + #Audio file convert + location /api/ngx/audio/convert { + content_by_lua_file $resty_loc/resty_funcs/audio_convert.lua; + } #Static file server location /file_upload { default_type ""; diff --git a/music-room-test.conf b/music-room-test.conf index 1218966..2223131 100644 --- a/music-room-test.conf +++ b/music-room-test.conf @@ -72,6 +72,10 @@ server { location /api/ngx/image/combine { content_by_lua_file $resty_loc/resty_funcs/combine.lua; } + #Audio file convert + location /api/ngx/audio/convert { + content_by_lua_file $resty_loc/resty_funcs/audio_convert.lua; + } #Static file server location /file_upload { default_type "";