refactor lib

This commit is contained in:
2022-06-30 01:58:26 +08:00
parent 2357fa3d7e
commit af95a54aa1
6 changed files with 25 additions and 20 deletions
+6 -6
View File
@@ -1,10 +1,10 @@
local cjson = require "cjson"
--local cjson = require "cjson"
local TaskTypes = {
NOOP = 'NOOP',
UPLOAD_PICTURE = 'UPLOAD_PICTURE'
}
--
--local TaskTypes = {
-- NOOP = 'NOOP',
-- UPLOAD_PICTURE = 'UPLOAD_PICTURE'
--}
local task_server = ngx.var.task_server
+3 -3
View File
@@ -1,7 +1,7 @@
local cjson = require "cjson"
--local cjson = require "cjson"
--# https://github.com/SkyLothar/lua-resty-jwt
--$ opm get SkyLothar/lua-resty-jwt
local jwt = require "resty.jwt"
--local jwt = require "resty.jwt"
local function cleanupString(str, remove)
local lcSubStrTab = {}
@@ -63,7 +63,7 @@ local function verifyJwtToken(httpc, token)
end
local function decodeJwtClaim(jwtClaim)
local function decodeJwtClaim(jwtClaim, cjson, jwt)
local jwtKey = "0xCAFEBABE0xCAFEBABE0xCAFEBABE0xCAFEBABE0xCAFEBABE0xCAFEBABE"
local jwtObj = jwt:verify(jwtKey, jwtClaim)
+10 -8
View File
@@ -1,16 +1,18 @@
local cjson = require "cjson"
local pl = require "pl.pretty"
local sudoerToken = ngx.req.get_headers().HtySudoerToken
local htyhostHeader = ngx.req.get_headers().HtyHost
--local cjson = require "cjson"
--local pl = require "pl.pretty"
local function get_access_token(httpc)
local function get_access_token(httpc, cjson, pl)
local sudoerToken = ngx.req.get_headers().HtySudoerToken
local htyHostHeader = ngx.req.get_headers().HtyHost
local htyuc = ngx.var.htyuc
local host = ngx.var.host
local wx_domain = ngx.var.wx_domain
ngx.log(ngx.INFO, "HTYUC -> ", htyuc)
ngx.log(ngx.INFO, "Host -> ", host)
ngx.log(ngx.INFO, 'HtyHostHeader -> ', htyhostHeader)
ngx.log(ngx.INFO, 'HtyHostHeader -> ', htyHostHeader)
ngx.log(ngx.INFO, 'HtySudoerToken -> ', sudoerToken)
local remote_url = string.format("%s/api/v1/uc/wx_get_access_token", htyuc)
@@ -54,8 +56,8 @@ local function get_access_token(httpc)
end
local function get_wx_media(httpc, media_id)
local access_token = get_access_token(httpc)
local function get_wx_media(httpc, media_id, cjson, pl)
local access_token = get_access_token(httpc, cjson, pl)
print("access token: " .. access_token)
local wx_media_url = string.format("https://api.weixin.qq.com/cgi-bin/media/get?access_token=%s&media_id=%s", access_token, media_id)
print("wx_media_url: " .. wx_media_url)