fix: PAR注入ctx对象(httpClient+siteUrl+auth)对齐mediabo的httpGet模式
This commit is contained in:
@@ -84,7 +84,13 @@ public class GroovyScriptEngine {
|
|||||||
binding.setVariable("json", objectMapper);
|
binding.setVariable("json", objectMapper);
|
||||||
binding.setVariable("utils", new ScriptUtils());
|
binding.setVariable("utils", new ScriptUtils());
|
||||||
binding.setVariable("http", new HttpHelper(httpClient));
|
binding.setVariable("http", new HttpHelper(httpClient));
|
||||||
if (siteCtx != null) binding.setVariable("_ctx", siteCtx);
|
// 提供 ctx 对象,使 httpGet(ctx, path) 在 PAR 和 mediabo 中用法一致
|
||||||
|
Map<String, Object> ctx = new HashMap<>();
|
||||||
|
ctx.put("httpClient", httpClient);
|
||||||
|
if (siteCtx != null) {
|
||||||
|
ctx.putAll(siteCtx); // siteUrl, auth
|
||||||
|
}
|
||||||
|
binding.setVariable("ctx", ctx);
|
||||||
|
|
||||||
GroovyShell shell = new GroovyShell(classLoader, binding);
|
GroovyShell shell = new GroovyShell(classLoader, binding);
|
||||||
String fullScript = SCRIPT_PREFIX + groovyScript + "\n// PAR 调用入口\nreturn parse(content, url)";
|
String fullScript = SCRIPT_PREFIX + groovyScript + "\n// PAR 调用入口\nreturn parse(content, url)";
|
||||||
|
|||||||
Reference in New Issue
Block a user