[Add]: audio convert - get wx access token (#37)
This commit is contained in:
@@ -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)
|
||||
@@ -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 "";
|
||||
|
||||
@@ -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 "";
|
||||
|
||||
Reference in New Issue
Block a user