Reputation: 1494
I have a route builder that looks as follows:
.post("/myEndpoint")
.type(MyObject.class)
.to("bean:myListener?method=create")
I would like this to return a 201 Created HTTP Response Code, at present its returns a 200 OK.
Is there a way to do this in the RouteBuilder without having to forward any results onto a separate service class and then manually set the code on the Exchange?
Upvotes: 0
Views: 4074
Reputation: 1494
We managed to get it to work by doing the following -
.post("/myEndpoint")
.type(MyObject.class)
.route()
.setHeader(Exchange.HTTP_RESPONSE_CODE,simple(HTTP_CREATED))
.to("bean:myListener?method=create")
.endRest()
Upvotes: 3
Reputation: 3193
See the header section here http://camel.apache.org/constant.html for setting headers.. You should be able to set the http response code and body directly.
Upvotes: 0