Reputation: 1328
A RESTful POST request POST /request/{requestName}
POST /request/CreateProduct
{
"Code": 4711,
"Name": "My product"
}
is to be validated:
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
Is this possible with pure Camel? Or should I implement my own helper function? How to I include my own custom function in a Camel route?
Upvotes: 0
Views: 1126
Reputation: 36163
You can implement a customer processor as described here: http://camel.apache.org/processor.html
With the Exchange object you have access to header and body and can extract the necessary information to validate.
Upvotes: 1