RESTful POST请求POST /request/{requestName}
POST /request/CreateProduct
{
"Code": 4711,
"Name": "My product"
}
将被验证:
restConfiguration().component("netty4-http").port(8080).bindingMode(RestBindingMode.json);
rest("request/{requestName}").post()
.consumes("application/json; charset=UTF-8")
.produces("application/json; charset=UTF-8")
.to("direct:newRequest");
from("direct:newRequest").transform().simple("Received request: ${header.requestName}, Body: ${in.body}");
id | name
------------------
1 | CreateProduct
2 | UpdateProduct
3 | DeleteProduct
id | name | type
-------------------
1 | Code | INT
2 | Name | STRING
2 | Price | INT
request | paramater | required
------------------------------
1 | 1 | 1
1 | 2 | 1
1 | 3 | 0
纯骆驼可以吗?或者我应该实现自己的帮助函数?如何在Camel路线中包含我自己的自定义功能?
答案 0 :(得分:1)
您可以按照此处所述实施客户处理器: http://camel.apache.org/processor.html
使用Exchange对象,您可以访问标题和正文,并可以提取必要的信息进行验证。