THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block |
---|
onException(JsonParseException.class) .handled(true) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(400)) .setHeader(Exchange.CONTENT_TYPE, constant("text/plain")) .setBody().constant("Invalid json data"); |
Parameter default Values
You can specify default values for parameters in the rest-dsl, such as the verbose parameter below:
Code Block |
---|
rest("/customers/")
.get("/{id}").to("direct:customerDetail")
.get("/{id}/orders")
.param().name("verbose").type(RestParamType.query).defaultValue("false").description("Verbose order details").endParam()
.to("direct:customerOrders")
.post("/neworder").to("direct:customerNewOrder"); |
From Camel 2.17 onwards then the default value is automatic set as header on the incoming Camel Message
. So if the call the /customers/id/orders
do not include a query parameter with key verbose
then Camel will now include a header with key verbose
and the value false
because it was declared as the default value. This functionality is only applicable for query parameters.
Integrating a Camel component with Rest DSL
...