[
https://issues.apache.org/jira/browse/CAMEL-24884?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-24884.
---------------------------------
Resolution: Fixed
> camel-core - resolveResource option on expressions: a returned resource:...
> value is loaded and its content is the result
> -------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-24884
> URL: https://issues.apache.org/jira/browse/CAMEL-24884
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Reporter: Claus Ibsen
> Priority: Major
> Fix For: 4.23.0
>
>
> The {{resource:}} prefix is resolved on the text of an expression
> ({{constant: "resource:file:order.json"}}, {{simple:
> "resource:file:${...}"}}, {{groovy: "resource:file:script.groovy"}}), never
> on a value an expression returns. Choosing a file per message in any language
> but Simple therefore takes two steps, a setHeader with the script and a
> setBody with {{simple: "resource:file:${header.x}"}}; and a script that
> returns {{'resource:file:order.json'}} hands the route that text, which is
> what the local model did in the camel-jbang-mcp stepwise benchmark
> (CAMEL-24882).
> Add an opt-in boolean {{resolveResource}} on the expression definition, so it
> applies to every language: when true and the evaluated result is a String
> starting with {{resource:}}, the expression resolves it through the same
> ScriptHelper lookup the prefix uses today and returns the resource's content
> as the result. Default false, so a body that happens to hold that text never
> changes. The loaded content is the final value, not evaluated again.
> {code}
> - setBody:
> expression:
> groovy:
> expression: "counter == 1 ? 'resource:file:order.json' :
> 'resource:file:order-bad-email.json'"
> resolveResource: true
> - setBody:
> expression:
> jq:
> expression: "\"resource:classpath:templates/\" + .type + \".json\""
> resolveResource: true
> {code}
> The second form is the general use: a template or a document chosen from the
> message (resource:orderTemplate.json, resource:classpath:...). The validator
> hint of CAMEL-24882 then offers this flag as the in-place fix next to
> constant/simple. Schema, catalog and the DSLs pick the option up from the
> model.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)