Files
resty_functions/audio_convert.lua
T

49 lines
1.3 KiB
Lua

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)