Skip to content

后置任务定义

存在这种场景:同步请求返回,异步线程处理逻辑,将结果回调上游。

对于这种场景进行了后置任务抽象,现有后置任务定义:

  • HTTP_TASKhttp请求任务

HTTP_TASK 定义

支持类型:

  • GET Request Param类型:请求参数的Get请求
  • POST FormData类型:form表单数据的Post请求
  • POST JSON类型:请求体为json格式的Post请求

格式:

json
{
  "type": "HTTP_TASK",
  "content": {
    "url": "url",
    "payloadType": "application/json | application/x-www-form-urlencoded",
    "payload": "payload",
    "method": "GET|POST"
  }
}
  • typeHTTP_TASK
  • url:请求的url
  • payloadType:请求体的类型,application/json | application/x-www-form-urlencoded
  • payload:请求体内容,使用freemarker模板引擎,支持freemarker语法标签,model赋值见变量。
  • method:请求方法,GET | POST

GET Request Param类型

举例:

json
{
  "type": "HTTP_TASK",
  "content": {
    "url": "http://127.0.0.1:9090/hello1",
    "payloadType": "application/json",
    "payload": "age=${p0.name}&name=${name}",
    "method": "GET"
  }
}

POST FormData类型

举例:

json
{
  "type": "HTTP_TASK",
  "content": {
    "url": "http://localhost:9090/hello2",
    "payloadType": "application/x-www-form-urlencoded",
    "payload": "age=${p0.name}&name=${name}",
    "method": "POST"
  }
}

POST JSON类型

举例:

json
{
  "type": "HTTP_TASK",
  "content": {
    "url": "http://127.0.0.1:9090/hello3",
    "payloadType": "application/json",
    "payload": "{\"age\":\"${p0.name}\",\"name\":\"${name!}\"}",
    "method": "POST"
  }
}