数据读写
模板渲染
type template
用 Freemarker 渲染模板
使用说明
要点:用 Freemarker 渲染模板,resourceUri 形如 classpath:templates/hello.ftl。示例先把 JSON 请求体转成 Map 作为数据模型。
属性
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
resourceUri模板资源 |
文本 | 必填 | — | classpath:templates/hello.ftl |
示例流程
可直接保存为 demo-template.json 并部署;非入口节点默认套了一个 REST 入口。
{
"id": "demo-template",
"desc": "模板渲染 示例",
"group": "示例/数据读写",
"schemaVersion": 1,
"nodes": [
{
"id": "n1",
"type": "rest",
"props": {
"method": "POST",
"path": "/demo/template",
"desc": "示例入口"
}
},
{
"type": "unmarshal",
"props": {
"format": "json",
"type": "java.util.Map"
},
"id": "n1"
},
{
"type": "template",
"props": {
"resourceUri": "classpath:templates/hello.ftl"
},
"id": "n2"
}
]
}
curl -X POST 'http://localhost:8086/flow' \
-H 'Content-Type: application/json' \
-H 'X-Flow-Token: change-me' \
--data-binary @demo-template.json
调用方式
如何触发:需要把模板文件放到宿主 classpath:templates/ 下;消息体作为 Freemarker 数据模型。