feat(ngx): NOOP IMAGE_FORM_COMPRESS audit after form_upload_to_compress
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
-- 压缩直传成功后向 Rust TS(3003)登记 NOOP,便于管理端 Tasks 可追溯(非 UPLOAD_PICTURE:后者专指 combine 管线)。
|
||||
local cjson = require("cjson")
|
||||
|
||||
local function create(httpc, auth_header, sudoer_token, public_url)
|
||||
local ts_host = ngx.var.huiwing_htyts_rust or "127.0.0.1:3003"
|
||||
local remote_url = "http://" .. ts_host .. "/api/v1/ts/create_task"
|
||||
local hty_host = ngx.req.get_headers()["HtyHost"] or ""
|
||||
local body_tbl = {
|
||||
task_type = "NOOP",
|
||||
payload = {
|
||||
kind = "IMAGE_FORM_COMPRESS",
|
||||
url = public_url,
|
||||
},
|
||||
}
|
||||
local body = cjson.encode(body_tbl)
|
||||
local res, err = httpc:request_uri(remote_url, {
|
||||
ssl_verify = false,
|
||||
method = "POST",
|
||||
headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["Authorization"] = auth_header or "",
|
||||
["HtySudoerToken"] = sudoer_token or "",
|
||||
["HtyHost"] = hty_host,
|
||||
},
|
||||
body = body,
|
||||
})
|
||||
if not res then
|
||||
ngx.log(ngx.ERR, "IMAGE_FORM_COMPRESS audit: request failed ", err)
|
||||
return false
|
||||
end
|
||||
if res.status ~= 201 and res.status ~= 200 then
|
||||
ngx.log(ngx.ERR, "IMAGE_FORM_COMPRESS audit: status=", res.status, " body=", res.body)
|
||||
return false
|
||||
end
|
||||
ngx.log(ngx.INFO, "IMAGE_FORM_COMPRESS audit noop created")
|
||||
return true
|
||||
end
|
||||
|
||||
return { create = create }
|
||||
Reference in New Issue
Block a user